Kelly Martens
asked on
WMI Remote Server File Path To Execute Script in ASP.NET webservice
I am trying to use WMI to run a script on a remote server with a vb,net ASP.NET webservice. I connect fine to the server. But I know from a log entry that works locally that the log entry is not being recorded on the remote server so it is not executing. I think somehow the path to the file is in error. If anyone can help I would be very grateful. I don't think it is permissions as for now I have given access to 'Everybody' so I could rule that out.
'\\dev-sql-a\ShippingSyste m\Wave
CreateProcess("DEV-SQL-A", "C:\\ShippingSystem\\Wave\ \Wave.vbs" , "Domain\Username", "password")
' CreateProcess("DEV-SQL-A", "C:\ShippingSystem\Wave\Wa ve.vbs", "Domain\Username", "password")
<code>
Private Sub CreateProcess(ByVal strComputer As String, ByVal strProcess As String, ByVal UserName As String, ByVal Password As String)
Dim processBatch As ManagementClass = New ManagementClass("Win32_Pro cess")
Dim inParams As ManagementBaseObject = processBatch.GetMethodPara meters("Cr eate")
Dim msc As ManagementScope
inParams("CurrentDirectory ") = Nothing
inParams("CommandLine") = strProcess
Dim co As ConnectionOptions = New ConnectionOptions()
co.Username = UserName
co.Password = Password
Try
If (strComputer = System.Environment.Machine Name) Then
msc = New System.Management.Manageme ntScope("\ \" & strComputer & "\root\cimv2")
Else
msc = New System.Management.Manageme ntScope("\ \" & strComputer & "\root\cimv2", co)
End If
msc.Connect()
processBatch.Scope = msc
Dim meyhodoptions As InvokeMethodOptions = New InvokeMethodOptions(Nothin g, System.TimeSpan.MaxValue)
Dim outParamas As ManagementBaseObject = Nothing
outParamas = processBatch.InvokeMethod( "Create", inParams, Nothing)
Catch ex As Exception
End Try
End Sub
<code/>
'\\dev-sql-a\ShippingSyste
CreateProcess("DEV-SQL-A",
' CreateProcess("DEV-SQL-A",
<code>
Private Sub CreateProcess(ByVal strComputer As String, ByVal strProcess As String, ByVal UserName As String, ByVal Password As String)
Dim processBatch As ManagementClass = New ManagementClass("Win32_Pro
Dim inParams As ManagementBaseObject = processBatch.GetMethodPara
Dim msc As ManagementScope
inParams("CurrentDirectory
inParams("CommandLine") = strProcess
Dim co As ConnectionOptions = New ConnectionOptions()
co.Username = UserName
co.Password = Password
Try
If (strComputer = System.Environment.Machine
msc = New System.Management.Manageme
Else
msc = New System.Management.Manageme
End If
msc.Connect()
processBatch.Scope = msc
Dim meyhodoptions As InvokeMethodOptions = New InvokeMethodOptions(Nothin
Dim outParamas As ManagementBaseObject = Nothing
outParamas = processBatch.InvokeMethod(
Catch ex As Exception
End Try
End Sub
<code/>
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
I am following up on your question. Do you still need help?
If you solved the problem on your own, would you please post the solution here in case others have the same problem?
Regards,
Kyle Santos
Customer Relations