troubleshooting Question

.NET Web Service call to run script on remote machine using WMI

Avatar of Kelly Martens
Kelly Martens asked on
Remote AccessVisual Basic.NETVB ScriptC#
8 Comments1 Solution184 ViewsLast Modified:
I need to run a vbs script on a remote machine from WMI in a vb.net web service. The path of the vbs file on the remote machine is called
C:\ShippingSystem\Wave\wave.vbs

What I have so far.... (Remote Machine, Path on the remote machine, username, password)

Sub RunIt()
CreateProcess("REMOTEMACHINE", "C:\ShippingSystem\Wave\Wave.vbs", "DOMAIN\USERNAME", "password")
End Sub

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_Process")
        Dim inParams As ManagementBaseObject = processBatch.GetMethodParameters("Create")
        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.MachineName) Then
                msc = New System.Management.ManagementScope("\\" & strComputer & "\root\cimv2")
            Else
                msc = New System.Management.ManagementScope("\\" & strComputer & "\root\cimv2", co)
                'msc = New System.Management.ManagementScope("\\" & strComputer & "\root\cimv2", co)
            End If

            msc.Connect()

            Debug.WriteLine(msc.Path)
            processBatch.Scope = msc

'WHERE DO I GO FROM HERE

End Sub
ASKER CERTIFIED SOLUTION
Kelly Martens

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros