I have spent the last 9 hours trying every possible solution I could find on the web. But nothing works. My primary goal is to reboot a computer on the network. It seems like it should be very easy using shell and/or a batch file. Here is my latest attempt (sorry I don't know how to separate the code):
Dim p As New Process
With p
.StartInfo.CreateNoWindow = True
.StartInfo.UseShellExecute = False
.StartInfo.RedirectStandardOutput = True
.StartInfo.RedirectStandardError = True
.StartInfo.FileName = "rebootcomp.bat"
End With
p.start()
The above code actually runs the batch file without any errors. Just for testing I had the batch file execute c:\windows\system32\notepad.exe and calc.exe and freecell.exe. All those work. But if I try to open cmd.exe or shutdown.exe it does nothing at all.
Below are all the other things I have tried and the errors that I got:
'p.StartInfo.FileName = "C:\windows\system32\shutdown.exe"
'p.StartInfo.Arguments = "-r"
'p.Start()
'error = The system cannot find the file specified
'I can't even do the code below at all
'Dim location As New Process
'location.Start("C:\rebootcomp.bat")
'vb likes this better, but it still doesn't do anything
'Process.Start("C:\rebootcomp.bat")
'Process.Start("C:\test.bat")
'error = in the dos prompt "C:\windows\system32\shutdown.exe is not recognized as an internal or external command.
'Heres the deal, everything works perfectly if I open a dos prompt and run it.
'Nothing works at all is vb opens the exact same dos prompt C:\windows\system32\cmd.exe
'Process.Start("shutdown", "-s -m \\Marklar")
'Process.Start("shutdown", "/r")
'error = The system cannot find the file specified
'Dim l_PRC As New Process
'l_PRC.StartInfo.Arguments = "/r /t 10"
'l_PRC.StartInfo.FileName = "c:\windows\system32\shutdown.exe"
'l_PRC.Start()
'Dim sCommand As String
'sCommand = "Shutdown -r -m \\" & comp & " /t 10"
'Shell(sCommand)
'System.Diagnostics.Process.Start("Shutdown", "/r /m \\" & comp & " /t 10")