
Starting process on remote computer
Try this....
Private Sub cmdOK_Click()
'Run exe on remote NT computer
'Requires project reference to "Window WMI Scripting Library"
'Requires Domain Name in Me.txtDomain and PC Name in Me.txtWSName on parent
form
Dim MyProc As WbemScripting.SWbemObject
Dim MyMethod As WbemScripting.SWbemMethod
Dim inParam As SWbemObject
Dim outParam As SWbemObject
Dim FName As String
Dim result As Variant
On Error GoTo 0
VncStartSuccess = False
Me.MousePointer = vbHourglass
FName = "WinMgmts:{impersonationLevel=impersonate,authority=ntlmdomain:" &
Trim$(Me.txtDomain) & "}!//" & Me.txtWsName & "/root/cimv2:Win32_Process"
On Error GoTo NoServer
Set MyProc = GetObject(FName)
Set MyMethod = MyProc.Methods_("Create")
Set inParam = MyMethod.InParameters.SpawnInstance_()
inParam.CommandLine = "calc.exe"
Set outParam = MyProc.ExecMethod_("Create", inParam)
Me.MousePointer = vbDefault
Set MyProc = Nothing
Me.Hide
Exit Sub
NoServer:
Me.MousePointer = vbDefault
MsgBox ("Startup error")
Set MyProc = Nothing
Me.Hide
End Sub
Quote:
> I need to start a EXE on a remote computer using VB. The remote system
could
> be Win9x or a flavor of NT. If NT, it would be a NT box where I am admin.
I
> have searched the NGs for information on how to do this. There are
numerous
> requests from folks who need this capability but no replies really offer a
> clear solution. For doing something seemingly simple it certainly appears
> much work must be done to implement it.
> Has anyone come across a simple clear solution for this yet? Something
that
> does not require writing to sockets or installing services on both
> computers. Possibly a high level API as a wrapper for this functionality?
> What is the easiest way to achieve this with the least amount of trouble?
> JR