‘xp_cmdshell’
EXEC sp_configure ’show advanced option’, ‘1′
EXEC sp_configure ‘xp_cmdshell’, ‘1′ RECONFIGURE WITH OVERRIDE;
Please run the following script before
Private Function ExecBatFile(ByVal BatchFilePath As String, ByVal ScriptFile As String, ByVal userid As String, ByVal password As String, ByVal strSqlServerInstanceName As String, ByVal strTempScriptFile As String) As Boolean
Dim CmdEx As New SqlCommand
Dim testconn As New SqlConnection(BuildConnectionString(userid, password, strSqlServerInstanceName, “master”))
Dim strCommand As String = String.Concat(New String() {” EXEC xp_cmdshell ‘”, ScriptFile, “\poc-bat.bat “”", userid, “”" “”", password, “”" “”", strSqlServerInstanceName, “”" “”", strTempScriptFile, “”"‘”})
Try
testconn.Open()
CmdEx.Connection = testconn
CmdEx.CommandType = CommandType.Text
CmdEx.CommandText = strCommand
CmdEx.ExecuteNonQuery()
Catch ex As Exception
Return False
End Try
Return True
End Function
-
Archives
- June 2009 (2)
- April 2009 (2)
- August 2008 (2)
- July 2008 (9)
- June 2008 (10)
- May 2008 (1)
- March 2008 (1)
- December 2007 (2)
-
Categories
-
RSS
Entries RSS
Comments RSS