Qousio Posted May 14, 2009 Posted May 14, 2009 (edited) Hello! I want to ShellExecute a .bat file. I have read the FAQ and help file on Shellexecute and Run functions, but that didnt really help... Usually this is how I run the .bat file: Command: %comspec% /k ""F:\Prog\VC2008\VC\vcvarsall.bat"" x86 I have tried this in autoit: ShellExecute("vcvarsall.bat", @ComSpec & " /k", "F:\Prog\VC2008\VC\") I have also tried several variations with parameters and the verb. But the .bat file instantly closes after launching. How do I prevent it from closing? Edited May 14, 2009 by Qousio
FinalVersion Posted May 14, 2009 Posted May 14, 2009 Hello!I want to ShellExecute a .bat file. I have read the FAQ and help file on Shellexecute and Run functions, but that didnt really help...Usually this is how I run the .bat file:Command: %comspec% /k ""F:\Prog\VC2008\VC\vcvarsall.bat"" x86I have tried this in autoit:ShellExecute("vcvarsall.bat", @ComSpec & " /k", "F:\Prog\VC2008\VC\")I have also tried several variations with parameters and the verb. But the .bat file instantly closes after launching.How do I prevent it from closing?Does that bat have "pause" in it? [center][+] Steam GUI [+][+] Clipboard Tool [+][+] System :: Uptime [+][+] StarCraft II Mouse Trap [+][/center]
Yashied Posted May 14, 2009 Posted May 14, 2009 (edited) Hello!I want to ShellExecute a .bat file. I have read the FAQ and help file on Shellexecute and Run functions, but that didnt really help...Usually this is how I run the .bat file:Command: %comspec% /k ""F:\Prog\VC2008\VC\vcvarsall.bat"" x86I have tried this in autoit:ShellExecute("vcvarsall.bat", @ComSpec & " /k", "F:\Prog\VC2008\VC\")I have also tried several variations with parameters and the verb. But the .bat file instantly closes after launching.How do I prevent it from closing?Console closed after BAT file has finished its work. To prevent this, do one of the following.ShellExecute("cmd.exe", "/k vcvarsall.bat " & @ComSpec & " /k", "F:\Prog\VC2008\VC\")Write the word PAUSE at the end of your BAT file. Edited May 14, 2009 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
Tankbuster Posted May 14, 2009 Posted May 14, 2009 (edited) I prefer RUN because of the "standard_i/o_flag" that give you the option to read output from the batch...$batch = Run(@ComSpec & " /c vcvarsall.bat ", "F:\Prog\VC2008\VC\", @SW_SHOW) while ProcessExists($batch) consolewrite("batch still running"&@CRLF) WEndMy example assumes that the batch starts and endsLike this one:@echo off echo Hello World xcopy folder1\*.* folder2\*.* /q /r /s /y pauseUntill the process exists you can see some console output. As soon as you press a key in the new window of the batch, the script continues.The stdout is not part of the example.I'm not stating that RUNis better or not than ShellExecute. I just do it this way... Edited May 14, 2009 by Tankbuster
Qousio Posted May 14, 2009 Author Posted May 14, 2009 Thanks for the info Yashied and Tankbuster, it works perfectly now.
InTheSky Posted February 17, 2014 Posted February 17, 2014 Sorry for reopening this topic but i have kind of the same issue. when i use the command below a cmd will open and the prompt is "C:UsersmyuserAppDataLocalmyprog>" but nothing else happens. What it should do is to run the file "rename.bat" and hand over the parameter "$ipath" & "$ifilename" & "$EnvVar". BTW full path to "rename.bat" is "C:UsersmyuserAppDataLocalmyprogrename.bat" Local $ipath = @ScriptFullPath Local $ifilename = @ScriptName Local $EnvVar = EnvGet("USERPROFILE") & "\AppData\Local\myprog" ShellExecute ("cmd.exe", "rename.bat" & " " & Chr(34) & $ipath & Chr(34) & " " & Chr(34) & $ifilename & Chr(34) & " " & Chr(34) & $EnvVar & Chr(34), $EnvVar & "\")
InTheSky Posted February 18, 2014 Posted February 18, 2014 Hey I found the mistake, this is how it works. ShellExecute ($EnvVar & "\rename.bat", Chr(34) & $ipath & Chr(34) & " " & Chr(34) & $ifilename & Chr(34) & " " & Chr(34) & $EnvVar & Chr(34))
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now