Problem: Using Psexec.exe in vb.net. Need Psexec.exe to exit or close itself

Problem: Using Psexec.exe in vb.net. Need Psexec.exe to exit or close itself

I am using Psexec.exe in vb.net to connect to remote pc’s, one at a time, run another executable file, which it does just fine and then terminate once psexec completes and exits with Error Code 0 (or Success).
This is what my command looks like running from Vb.net code: (See Below)

Am I missing another switch or command I’m missing to kill it. When I was in Debug, I couldn’t use either TaskKill or PsKill to kill the process name because it was part of the overall Project executable name.
I’m hoping someone has been through this before and may know exactly what I’m missing in my code.

Much Thanks,
Wallace

Code Snippet:
1:
2:
3:
Dim strCommand3 As String = """c:\program files\pvt updater\psexec.exe"" \\" & host & " -u " & "Domain\Username" & " -p " & "somePassword" & " -c ""c:\program files\pvt updater\PVT_Exec.exe"""
 
Shell(strCommand3)

 


Solution : Using Psexec.exe in vb.net. Need Psexec.exe to exit or close itself

I think what you want to use is something like the code sample below…

Using this technique allows you to do a bunch of things, just F1 on Process keyword  🙂

P.S.  UseShellExecute means that the process does not start as a child process of the application, but by the shell…  Not sure of the effects of this over the network, but it appears you are running a local process that accesses the network, so you should be fine.

1:
2:
3:
4:
5:
System.Diagnostics.Process prsQCG = new Process()
					prsQCG.StartInfo.FileName = strCommand3
					prsQCG.StartInfo.UseShellExecute = True
 
					prsQCG.Start()