EDN Admin
Well-known member
Morning Folks,
Im using the following bit of code to kick off remote processes on PCs - the idea being I can use it to call a .bat file to install a bit of software:
It works OK at the moment for various other bits and pieces. The problem Im encountering, is when I start the .bat file on a remote machine(its copied down by another sub that calls this one) it defaults to the System32 directory and hangs as it cant find the MSI its trying to install.
Is there anyway I can pass a Working Directory through to WMI so that it knows where to start the .bat file? or is there another way I should be doing this?
Apologies if this is the wrong forum
(the .bat file code is at the bottom) Public Sub WMI(ByVal PC, ByVal path, ByVal prgm)
Dim cmdline As Object = path & "" & prgm
Try
Dim WMIservice As Object
Dim obj As Object
Dim objins As Object
Dim objout As Object
WMIservice = GetObject("winmgmts:" & _
"{impersonationLevel=Impersonate}!\" & _
PC & "rootcimv2")
obj = WMIservice.Get("Win32_Process")
objins = obj.Methods_("Create").InParameters.SpawnInstance_
objins.CommandLine = cmdline
objout = WMIservice.ExecMethod("Win32_Process", "Create", objins)
MessageBox.Show( _
"PC Name = " & PC & vbCrLf & _
"Program running: " & cmdline & vbCrLf & _
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ")
Catch WMIex As System.Exception
throwex(WMIex)
Exit Sub
End Try
End SubMSIExec.exe /i "7ZIP000920.Msi" TRANSFORMS="7ZIP000920.MST" /QB! ALLUSERS=1 /QUIET /lv* "installer.log"
View the full article
Im using the following bit of code to kick off remote processes on PCs - the idea being I can use it to call a .bat file to install a bit of software:
It works OK at the moment for various other bits and pieces. The problem Im encountering, is when I start the .bat file on a remote machine(its copied down by another sub that calls this one) it defaults to the System32 directory and hangs as it cant find the MSI its trying to install.
Is there anyway I can pass a Working Directory through to WMI so that it knows where to start the .bat file? or is there another way I should be doing this?
Apologies if this is the wrong forum
(the .bat file code is at the bottom) Public Sub WMI(ByVal PC, ByVal path, ByVal prgm)
Dim cmdline As Object = path & "" & prgm
Try
Dim WMIservice As Object
Dim obj As Object
Dim objins As Object
Dim objout As Object
WMIservice = GetObject("winmgmts:" & _
"{impersonationLevel=Impersonate}!\" & _
PC & "rootcimv2")
obj = WMIservice.Get("Win32_Process")
objins = obj.Methods_("Create").InParameters.SpawnInstance_
objins.CommandLine = cmdline
objout = WMIservice.ExecMethod("Win32_Process", "Create", objins)
MessageBox.Show( _
"PC Name = " & PC & vbCrLf & _
"Program running: " & cmdline & vbCrLf & _
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ")
Catch WMIex As System.Exception
throwex(WMIex)
Exit Sub
End Try
End SubMSIExec.exe /i "7ZIP000920.Msi" TRANSFORMS="7ZIP000920.MST" /QB! ALLUSERS=1 /QUIET /lv* "installer.log"
View the full article