I have several Automation scripts that execute batch scripts (i.e. xxx.bat) using the Run Program activity. When the Automation runs, a big black cmd window opens and closes briefly during the batch step, see photo below. I've tried setting "Run Style = Minimized" in the activity, but this just causes the log to say "(myscriptname) did not respond to idle. Unable to change window state." Is there any way to stop this window from opening? One of the scripts is running via the scheduler and I would prefer that if a user is working at the time, this window doesn't pop up. Any suggestions are welcome!
If you're calling up anything more than just a command-line invocation of some program or utility
(e.g. executing notepad.exe, etc.), then this (adding an option to minimize the DOS command window) appears to be an enhancement suggestion,
so Quest Dev please take note.
I've tried a few methods, but none working so far... As a work-around, I wonder if you have to utilize a driver BAT file that calls up your invocations via START /min? Or maybe better yet, look into packaging/compiling the BATs as EXEs?
Thanks Gary! Earlier today I found a solution that seems to work. I'm using Tobias's code from How to run a batch file without launching a "command window"? - Super User and I created HideCmd.vbs with this content:
If WScript.Arguments.Count >= 1 Then ReDim arr(WScript.Arguments.Count-1) For i = 0 To WScript.Arguments.Count-1 Arg = WScript.Arguments(i) If InStr(Arg, " ") > 0 Then Arg = """" & Arg & """" arr(i) = Arg Next RunCmd = Join(arr) CreateObject("Wscript.Shell").Run RunCmd, 0, True End If
Then I put my HideCmd.vbs and my xxx.bat file into the same folder, and the Run Program activity has C:\Windows\System32\wscript.exe for the program, and two arguments (which are HideCmd.vbs xxx.bat) and the Run Directory is the folder containing the .vbs and .bat files. Here's a screenshot:
So far it seems to do just what I needed -- tonight will be the first "live" run with this new code...
P.S. Because my batch file resides on the server, when I ran the script I got the warning message "We can’t verify who created this file. Are you sure you want to run this file?"
To remove the error I followed the steps at this webpage How to Disable “Open File - Security Warnings” on Windows 10? | Windows OS Hub in the section Security Warning When Opening Files from the Network Share which said to go to Control Panel-Internet Options-Security-Local Intranet-Sites-Advanced-Add this website, and then I added my server UNC path as \\xxxxxxx