Keeping Command Console Open After Running Process
-
Hi Guys, I am running a command line application from inside my C# code, however it's failing and exiting out immediately. I'm trying to get the window to stay open after the program has finished running. I've tried the following: This opens the window, runs the script, fails and closes it: Process.Start(@"C:\Program Files\Inno Setup 5\iscc.exe", @"%dir%\MyInstallScript.iss"); This opens the window, keeps it open, and says: 'C:\Program' is not recognized as an internal or external command, operable program or batch file.: Process.Start("cmd.exe", "/k \"C:\\Program Files\\Inno Setup 5\\iscc.exe\" \"%dir%\\MyInstallScript.iss\""); Second one seems a bit weird, as i am wrapping everything in quotes as expected. Not sure what's going on here. Do i need to do something crazy like nesting the quotes? And if so, how would i do that? Any thoughts? Regards Tris
------------------------------- Carrier Bags - 21st Century Tumbleweed.
-
Hi Guys, I am running a command line application from inside my C# code, however it's failing and exiting out immediately. I'm trying to get the window to stay open after the program has finished running. I've tried the following: This opens the window, runs the script, fails and closes it: Process.Start(@"C:\Program Files\Inno Setup 5\iscc.exe", @"%dir%\MyInstallScript.iss"); This opens the window, keeps it open, and says: 'C:\Program' is not recognized as an internal or external command, operable program or batch file.: Process.Start("cmd.exe", "/k \"C:\\Program Files\\Inno Setup 5\\iscc.exe\" \"%dir%\\MyInstallScript.iss\""); Second one seems a bit weird, as i am wrapping everything in quotes as expected. Not sure what's going on here. Do i need to do something crazy like nesting the quotes? And if so, how would i do that? Any thoughts? Regards Tris
------------------------------- Carrier Bags - 21st Century Tumbleweed.
Hi, This looks straightforward but like you I cannot get it to work. I read the MSDN page on cmd.exe and the section on processing quotation marks left me completely baffled. http://technet.microsoft.com/en-us/library/bb490880.aspx[^] As with much of the stuff on MSDN it is missing a decent example. Can you understand what the /s switch does? May be I'm just thick but I don't think "Modifies the treatment of string after /c or /k" is an explanation. A simple solution or workaround for your problem would be to start a batch file, e.g.
Process.Start("setup.cmd", "\"%dir%\\MyInstallScript.iss\"");
where setup.cmd is
@echo off
C:\Program Files\Inno Setup 5\iscc.exe "%~1"
pauseIf you are concerned that the batch file could be modified by the user you could always have your program generate it just before it is required. Alan.
-
Hi Guys, I am running a command line application from inside my C# code, however it's failing and exiting out immediately. I'm trying to get the window to stay open after the program has finished running. I've tried the following: This opens the window, runs the script, fails and closes it: Process.Start(@"C:\Program Files\Inno Setup 5\iscc.exe", @"%dir%\MyInstallScript.iss"); This opens the window, keeps it open, and says: 'C:\Program' is not recognized as an internal or external command, operable program or batch file.: Process.Start("cmd.exe", "/k \"C:\\Program Files\\Inno Setup 5\\iscc.exe\" \"%dir%\\MyInstallScript.iss\""); Second one seems a bit weird, as i am wrapping everything in quotes as expected. Not sure what's going on here. Do i need to do something crazy like nesting the quotes? And if so, how would i do that? Any thoughts? Regards Tris
------------------------------- Carrier Bags - 21st Century Tumbleweed.
The entire command line after /k needs to be in quotes like so: Process.Start("cmd.exe", "/k \"\"C:\\Program Files\\Inno Setup 5\\iscc.exe\" \"%dir%\\MyInstallScript.iss\"\""); Note the extra quote characters at the start and the end of the argument after /k.
Eagles my fly, but weasels don't get sucked into jet engines.
-
The entire command line after /k needs to be in quotes like so: Process.Start("cmd.exe", "/k \"\"C:\\Program Files\\Inno Setup 5\\iscc.exe\" \"%dir%\\MyInstallScript.iss\"\""); Note the extra quote characters at the start and the end of the argument after /k.
Eagles my fly, but weasels don't get sucked into jet engines.
-
The entire command line after /k needs to be in quotes like so: Process.Start("cmd.exe", "/k \"\"C:\\Program Files\\Inno Setup 5\\iscc.exe\" \"%dir%\\MyInstallScript.iss\"\""); Note the extra quote characters at the start and the end of the argument after /k.
Eagles my fly, but weasels don't get sucked into jet engines.
Ah. Thank you. It's infuriating, i feel i was so close on my own! ^^
------------------------------- Carrier Bags - 21st Century Tumbleweed.