Completely invisible batch file.
I am trying to schedule a batch file to run completely invisible to the end user via KACE. It is running ok, but no matter what I try, it pops up a command prompt window for about a second. I have an invisible.vbs file that runs it completely invisible if I run it locally, and I have added it as a dependency on the KACE Script. Any help would be greatly appreciated.
The invisible.vbs script is this:
CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False
My KACE script is this:
@echo off
wscript.exe "invisible.vbs" "myfile.bat"
Answers (8)
There is no way to do this with a batch file alone. however if you truly require your batch file to not popup a window you can create and run the following vbs script to do exactly what you want
Set WshShell = CreateObject("WScript.Shell" )
WshShell.Run chr(34) & "yourfile.bat" & Chr(34), 0
Set WshShell = Nothing
Copy the lines above to Notepad and save the file with .VBS extension. Now you just have to copy both files and call the vbs script.
Comments:
-
Should read..
Set WshShell = CreateObject("WScript.Shell" )
WshShell.Run chr(34) & "C:\Batch Files\syncfiles.bat" & Chr(34), 0
Set WshShell = Nothing - RandomITPro 12 years ago -
I have tried this, and while it works perfectly when it is ran locally, when I push it from KACE it still pops up a command prompt. It is there for less than a second, so it's not a huge deal, but I would rather the end user not see anything at all. - WGM_Jeff 12 years ago
I use a Bat to Exe converter that has an option to compile the exe to run invisible. There are quite a few out there, but I've been using this one http://www.f2ko.de/programs.php?lang=en&pid=b2e
you could look into using the NirCmd tool (http://www.nirsoft.net/utils/nircmd.html). It should allow you to run your VBS by using the execmd parameter, and should execute this without anything visible on screen.
A batch file is called by come.exe so there will always be that flash as it is called and then control handed back. You can't get rid of this in batch only behaviour in any reasonable way that I have seen.
You can make the flash so slight as to be almost imperceptible by renaming your batch as a .cmd file and adding @echo off as the first line. Since control isn't passed to a batch the flash is greatly reduced to be almost unnoticeable.