473,326 Members | 2,173 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

process.start and cmd.exe

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")
Sep 28 '11 #1
0 2095

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: James Li | last post by:
I need to run multiple .bat files(in specific order, sychronously) from my C# windows app. I also want to hide the DOS command window so that users don't see them. Basically my program lanches...
10
by: Tony | last post by:
I am running an application called AcroComm.exe to poll time clocks here at our company. I have written a small C# app that will poll the clocks based on information found in a DB. My problem is...
5
by: Robert Megee | last post by:
I can't get Process.Start() to work from a Web application. Is this because of the security settings in the browser? Since this is for a private network, security isn't an issue. Anyone know how...
5
by: Dean Slindee | last post by:
I have looked everywhere I can think of for the .exe name of the Windows Picture and Fax Viewer. Anybody know what it's named? Thanks, Dean Slindee
2
by: andreas | last post by:
hi, In windows xp in the start launch menu when i put notepad "c:\test.txt" i get notepad with test.txt in it. in vb.net when i state system.diagnostics.process.start("notepad.exe" i get...
0
by: henning.friese | last post by:
Hello NG, I'm need to write some code which creates tiff files from various document types (doc, pdf, xls). I want to do this by ShellExecuting (via System.Diagnostics.Process) the doc-files...
0
by: Kirk | last post by:
The following C# web service works fine until you uncomment the lines setting UserName and Password. Then, Process.Start throws an Access is Denied Exception. This is with .NET 2.0, of course...
2
by: Daniel | last post by:
System.Diagnostics.Process.Start fails on windows server 2003 the process returns process.ExitCode == 0 but executing any process with System.Diagnostics.Process.Start on windows xp works fine....
4
by: Paul | last post by:
Hi, I am trying to start a process hidden. My code: wordprocess = new System.Diagnostics.Process(); ; wordprocess.StartInfo = new System.Diagnostics.ProcessStartInfo(wcmd, args);...
5
by: sjoshi23 | last post by:
Hello I'm trying to start a remote desktop session using Process.Start but it keeps saying "File not found". The same cmd thru DOS window works fine. I used: C:\\WINDOWS\\system32\\mstsc.exe...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.