Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking for some way to run a batch file (.bat) without anything visible to the user (no window, no taskbar name, .etc..).

I don't want to use some program to do that, I'm looking for something cleaner. I've found a solution that uses VBScript, but I don't really like using VBS, either.

share|improve this question
3  
Windows 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 Oct 29 '09 at 14:03
1  
I has a Windows service that runs batch files. Not that the service is a batch file. – Moayad Mardini Oct 29 '09 at 18:37
1  
What language are you writing your service in? – Hugh Allen Oct 30 '09 at 5:53

17 Answers 17

up vote 47 down vote accepted

Solution 1:

Save this one line of text as file invisible.vbs:

CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False

To run any program or batch file invisibly, use it like this:

wscript.exe "C:\Wherever\invisible.vbs" "C:\Some Other Place\MyBatchFile.bat"

To also be able to pass-on/relay a list of arguments use only two double quotes

CreateObject("Wscript.Shell").Run "" & WScript.Arguments(0) & "", 0, False

Example: Invisible.vbs "Kill.vbs ME.exe"

Solution 2:

Use a command line tool to silently launch a process : Quiet, hidecon or hideexec.

share|improve this answer
1  
@Starx VB syntax. & means concatenate strings. Strings are enclosed in double quotes ("). Consecutive double quotes ("") inside string delimiters means a literal double quote ("). So, four double quotes ("""") would be a string literal of one character, a double quote ("). Put it together, and """" & WScript.Arguments(0) & """" would become "<argument>", where <argument> is the first command line argument passed to the script. – Bob Dec 17 '12 at 17:39
1  
How to modify it so it passes all arguments? It would be more convenient to pass the arguments without quoting them. – Ctrl-C Jun 12 '15 at 14:13

To Hide batch files or command files or any files.... Use Windows XP built in Iexpress.exe utility to build a .EXE out of the batch file. When using Iexpress make sure you check the run hidden option and check mark all the boxes about not showing anything. After you create your .exe place it in whatever run command folder you choose and you will never see it come up.

share|improve this answer
1  
Oh, good solution actually. – Camilo Martin Sep 8 '12 at 1:34
3  
is there anything equivalent to lexpress.exe in newer windows versions like windows 7? – Suhail Jun 23 '15 at 5:00

use Cmdow is a Win32 commandline utility for NT4/2000/XP/2003 that allows windows to be listed, moved, resized, renamed, hidden/unhidden, disabled/enabled, minimized, maximized, restored, activated/inactivated, closed, killed and more.

Run a batch file hidden passing it parameters:-

cmdow /run /hid mybat arg1 "arg 2"

share|improve this answer
5  
cmdow is detected as a malware by most antivirus products. Hence it would be difficult to use this solution in places other than you own PC. – Ganesh R. Oct 29 '09 at 13:02

Seems that somebody made a list of the 7-8 ways to run 'silent':

http://forums.techguy.org/dos-other/644932-solved-howto-run-batch-file.html

share|improve this answer

Run the script via an at job without making it interactive:

at 11:00 script.bat


Another solution, if you don't mind installing something like Python, you could simply create a script and run it with pythonw (the linked version for GUI operations). Since you aren't using any graphical APIs, the window will not show. Simply use calls to os.system() and it will mimic a batch script, as it is the same as typing the strings into the command line.

Example:

import os

os.system("tasklist > C:\tasks.txt")
os.system("ipconfig /all > C:\netinfo.log")
share|improve this answer
1  
But how would I run this command? – Moayad Mardini Oct 29 '09 at 13:07

If your Batch File can fit into one line and so many characters, then just use a Shortcut by right clicking inside a folder put in a random directory, and skip through the rest of the wizard, and lastly right click on the shortcut just created and click properties and under target, input what you would usually put in a bat file. And Bobs your uncle!

Pros:

 No Command Window
 Ability to use an icon
 Same Functionality of bat file

Cons:

 Limited to one line, so many characters
share|improve this answer

You can run it minimized easily.

start /MIN batch.cmd
share|improve this answer

Using Windows7, you can use the "Scheduled Task" control panel to schedule a batch file to run in the background invisibly with specified permissions and even as the "SYSTEM" account. See screenshot below:

enter image description here

Furthermore, although with not as many capabilities, you can also create a invisible batch script task like this from the command line using the "AT.exe" command without the '/interactive' option.

share|improve this answer

You do not need to do any special.

If you are running the batch files from a windows service, they should be hidden by default unless you enable the "Allow service to interact with desktop" option on the service.

share|improve this answer

I don't like VBScript solution.

Download and copy nircmd.exe to your %systemroot%\system32 folder, then add this command to first line of your batch:

nircmd.exe win hide ititle "cmd.exe"

or make your batch title custom first with title command to avoid from hiding all cmd windows, like this:

title MyBatch
nircmd.exe win hide ititle "MyBatch"
share|improve this answer
cmdow /run /hid "file.extention" arg1 "arg 2"
share|improve this answer
1  
Please include brief explanation of the command. That might help the OP (and others) understand how it works instead of just copying the command and using it. – BloodPhilia Jan 26 '11 at 20:07

I had the same problem, but figured it out:
Shell("filehere" & "parametersforbatchfilehere", vbHidden)

share|improve this answer

This works for windows 8 (possibly others)

  1. Create a batch file as normal
  2. Create a shortcut to the batch file
  3. Right click on the shortcut > properties
  4. Click Layout
  5. Untick "Let system position window"
  6. set left position tp -1000
  7. click apply

  8. Click on the shortcut and it will run but you wont see it :)

share|improve this answer
1  
Really? This won't show as a button on the taskbar? – Scott Aug 16 '14 at 0:23

I started trying to figure this out and never really succeeded. This was as close as I got:

@echo off
if not defined PIL (
    set PIL=1
    start /min "" %~0
    exit /b
)
TITLE Hello World
echo Hello world!
pause>nul
share|improve this answer

I did it successfully with nircmd this way:

  1. download nircmd.exe from web
  2. create your .bat file
  3. the first line of .bat file has to be this: nircmd.exe win hide ititle "cmd.exe"
  4. select both files and create a self extract file using winrar
  5. in "general" tab, check "create autoextract file" box
  6. in "advance" tab select "autoextract" button
  7. there is a new window and select "mode" tab then select option: "hide everything"
  8. select tab "update" and select option "overwrite existing files"
  9. Select "general" tab and define a destination folder for extraction if you wish and in the box "Excecute after extraction" write the full path where your .bat will be extracted. Ex: if you define extraction folder as: "c:\windows\" then the full path to excute after extraction will be: "c:\windows\file.bat" (in the case your .bat is named: file.bat)
  10. click accept on all windows

Now you will have a .exe file that after you doble click on it and install it, your .bat will run totally hided.

ZEUS

share|improve this answer

Here I've compiled all ways that I know to start a hidden process with batch without external tools.With a ready to use scripts (some of them pretty rich on options) , and all of them form command line.Where is possible also the PID is returned .Used tools are IEXPRESS,SCHTASKS,WScript.Shell,Win32_Process and JScript.Net

share|improve this answer

Adding my answer here from another post since it was a duplicate and I don't see this solution here so now there are 17 different answers for how you can run a batch file hidden. I will delete my answer on that post at some point in the near future.

Create your batch script with your batch logic and commands in it, and then create a new file with .VBS extension, use the below logic (example I provided below) and just plug in the full path to your .CMD or .BAT file with the PING -t <IPAddress>, etc. commands so it executes the batch in a hidden manner not showing the command window when it is executed.

Where the logic in the example below specifies C:\Folder\BatchFileName.cmd change that to point to the batch script with your commands you are running manually, etc. now.

Save the .VBS file and schedule it with Task Scheduler Problems scheduling a task on windows7 to run on an indefinite schedule for your needs.

Otherwise, just double-click on the .VBS file to run the infinite PING command you put in the batch file you point it to as-needed.

NOTE: I believe this is where I got this script logic from but it works reliably for the same purpose you need here which is to ensure the command window is hidden when a batch file is run Server Fault Source

EXAMPLE VBS SCRIPT RUN COMMAND LINE BATCH HIDING CMD WINDOW

Set WinScriptHost = CreateObject("WScript.Shell")
WinScriptHost.Run Chr(34) & "C:\Folder\BatchFileName.cmd" & Chr(34), 0
Set WinScriptHost = Nothing
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.