I needed to hide the window for a batch file called from an explorer context menu, and also needed to add quotes on the parameter. None of the answers worked for me, so I'm adding my own solution.
I had this on the registry "command" for an explorer context menu:
cmd /c C:\mypath\myprogram.bat "%1"
So to replace it I had to create a vbs like this:
WScript.CreateObject ("WScript.shell").run "cmd /c C:\mypath\myprogram.bat """ & WScript.Arguments(0) & """", 0, False
Save in a place like C:\mypath\myscript.vbs
and call it like this on the registry:
wscript "C:\mypath\myscript.vbs" "%1"
Note that the .bat path can't have spaces, so replace it with the 8.3 filename. So for instance C:\Program Files\myprogram.bat
have to be referenced as C:\Progra~1\myprogram.bat
. To see the 8.3 filename use dir /x
If you're already developing a service, why not use NSSM to create a service out of your compiled file? – KnightOfNi – 2014-10-21T23:52:03.497
Just to add to the list of programs - Hidden Start.
– Karan – 2015-05-06T07:56:53.023I think your link is down. – Artemis still doesn't trust SE – 2018-05-26T15:05:17.117
"a solution" has link rotted, archive here
– Shaun Dreclin – 2018-09-14T03:12:45.953Haha! Definitely not. I'm developing a Windows service which will run a batch file every now and then. – Moayad Mardini – 2009-10-29T12:53:34.757
4Windows services don't run as batch files. They run as services. You need to clarify the question--as written and with comments it makes no sense to me. – CarlF – 2009-10-29T14:03:16.293
1I has a Windows service that runs batch files. Not that the service is a batch file. – Moayad Mardini – 2009-10-29T18:37:23.367
1What language are you writing your service in? – Hugh Allen – 2009-10-30T05:53:25.177
there is hstart too. – barlop – 2013-12-10T20:55:18.710