Run Vbs File From CMD
Ok i'm trying to create a vbscript that will run schtasks to create a task in the cmd Dim objShell Set objShell = Wscript.CreateObject ('Wscript.shell') objShell.Run 'CMD /K. SOLVED VBscript to run a command in command prompt - IT Programming - Spiceworks.
Categories: Command Prompt
In other languages:
Русский: запустить пакетный файл с помощью командной строки в Windows, Italiano: Eseguire un File Batch dal Prompt dei Comandi di Windows, Deutsch: Unter Windows über die Kommandozeile eine Batch Datei ausführen, Español: ejecutar un archivo batch desde la línea de comandos en Windows, Nederlands: Een batchbestand uitvoeren in Windows, Português: Executar Arquivos em Lote Pela Linha de Comando no Windows, Bahasa Indonesia: Menjalankan Berkas Batch dari Baris Perintah di Windows, العربية: تشغيل ملف باتش من سطر الأوامر في ويندوز, 中文: 在Windows电脑上通过命令行运行批处理文件, Tiếng Việt: Thực thi tập tin batch từ dòng lệnh trên Windows, ไทย: เปิดไฟล์ Batch ด้วย Command Line ของ Windows, Français: exécuter un fichier batch à partir de la ligne de commande sur Windows
- Edit
- Send fan mail to authors
Run Vbs File From Cmd 2017
Batch files are a handy way to execute a series of commands in Windows, but is there anyway to run them invisibly in the background? Read on find out how.
Today’s Question & Answer session comes to us courtesy of SuperUser—a subdivision of Stack Exchange, a community-driven grouping of Q&A web sites.
The Question
SuperUser reader Jake wants to run a BAT file invisibly, he writes:
I have installed a ruby gem called Redcar, which is launched from the command line. When it runs, it steals the shell until it terminates, so I have to create a new shell window to continue doing command line work. The shell I’m using is the GITBash shell from MySysGit.
I found a Redcar.bat file which is meant to launch Redcar as a shortcut, I presume, but I don’t want the extra command prompt window to open whenever I launch the BAT file.
How do I just run the BAT without seeing the prompt?
Is there a solution for Jake’s stealthy prompt desire?
The Answers
SuperUser contributor Afrazier responds with a combination of bad and good news:
You can’t — executing a batch file with the built in Command Prompt is going to keep a window open until the batch file exits.
What you can do is take steps to make sure that the batch file exits as quickly as possible. If at all possible, modify the batch file to run whatever program with the start
command. By default, start
returns immediately without waiting for the program to exit, so the batch file will continue to run and, presumably, exit immediately. Couple that with modifying your shortcut to run the batch file minimized, and you’ll only see the taskbar flash without even seeing a window onscreen.
One caveat to this is that if you’re running a console-mode program, which many script interpreters are, the batch file will wait for the program to exit, and using start
will spawn a new console window. What you need to do in this case is run the Windows-based version of the interpreter instead of the console-based one — no start
necessary. For Perl, you would run wperl.exe
instead of perl.exe
. For Python, it’s pythonw.exe
instead of python.exe
. The old win32 Ruby distribution I have downloaded has rubyw.exe
, which should do the same thing.
A final possibility is to use a 3rd-party tool to run the command prompt with a hidden window. I’ve heard of such things but never had a use for them, so I don’t know of anything in particular to point you to.
Readers also pointed him to another SuperUser thread that highlights how you can use a Visual Basic Script to go beyond minimizing the visibility and outright hide the CMD prompt. In that thread, Harry MC explains:
Solution 1: Vishnu movie hd video songs free download.
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:Whereverinvisible.vbs” “C:Some Other PlaceMyBatchFile.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
eg: Invisible.vbs “Kill.vbs ME.exe”
Solution 2:
Use a command line tool to silently launch a process : Quiet.
Employing any of the above solutions, based on your comfort level using VBS and third party tools or not, will at minimum reduce the visibility of the CMD window or outright remove it.
Have something to add to the explanation? Sound off in the the comments. Want to read more answers from other tech-savvy Stack Exchange users? Check out the full discussion thread here.
READ NEXTRun Vbs File From Command Line
- › What Can I Do with My Old iPhone?
- › How to Stream UFC 242 Khabib vs. Poirier Live Online
- › Free Download: Microsoft’s PowerToys for Windows 10
- › How to Overclock Your Computer’s RAM
- › What’s New in Chrome 77, Arriving September 10