Run command prompt in background silently (without opening a window)


If you like programming shell scripts for Windows, you might want to run your command prompt scripts in the background silently without actually opening the command prompt windows. This easily possible with a few lines of vbscript.

Running command prompt in background silently

Using VBScript To Run CMD Script Silently

Here’s a little snippet of one of my command prompt scripts:


rundll32.exe %SystemRoot%\system32\shell32.dll,Control_RunDLL %SystemRoot%\system32\desk.cpl desk,@Themes /Action:OpenTheme /file:"C:\Windows\Resources\Themes\landscapes.theme"

Let’s say you don’t want Windows 7 to open a command prompt window and run it silently, you can write a vbscript for that:

1. Open a notepad editor

2. Insert the following code:


Set WshShell = CreateObject("WScript.Shell")
cmds=WshShell.RUN("E:\scripts/themescript.bat", 0, True)
Set WshShell = Nothing

The 0 makes the shell script run silently.

3. Save your notepad file. When you save it add the extension .vbs and select All files from the dropdown as seen below:
Save VBScript

4. You can now schedule that cmd script and it will not open a command prompt window

This is very handy if you don’t want to be annoyed with dozens of command prompt windows when your scheduled tasks are running.

You might also want to know how to open the command prompt in Windows 8

Rate this article:
This article was rated 5 out of 5 stars
Based on 3 votes

How to automatically correct text while you type or replace strings
How to save notepad as .html, .bat, .xml, .csv
Quickly Locate Huge Files To Free Disk Space

Juicy Logo White You love Windows, Gaming and everything digital? Great, we too! We have thousands of great Windows 7 themes, registry tweaks, tutorials, so please use our search box if you look for anything specific.

If you have some awesome desktop themes, tips or want to write for us, then drop us a mail!



Written by: Oliver Krautscheid (Nick: oliversk)
Oliver is the founder and lead editor of this site. He is interested in finding new ways to break Windows, find common e.... Full Bio

Contact The Author: support@windows7themes.net Get Free Help.png

Connect:

facebook google twitter LinkedIn


Need help? Ask a question at our QA site, click the red button to get started:

2 Responses to Run command prompt in background silently (without opening a window)

  1. sels said:

    here is a simple command for that:


    Set ws=CreateObject("WScript.Shell")
    ws.Run "TASKKILL.exe /F /IM iexplore.exe"

  2. oliversk said:

    Thanks sels, that might come in handy.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>