Solved

windows OS: how to run script in background

Posted on 2014-04-19
5
2,117 Views
Last Modified: 2014-04-22
we are having some windows scripts with .bat extention,
by its nature when we ran those scripts,  cmd console will be kept open & listening for request  service request. incase we dont need any more, either we close console window or press CTRL+C,  to comeOut of running console window.then eventually service will stop running.

my requirement is -
how to make these script running in backgrond. just like a feature Unix, where a script can be run in background using following command
 #script.sh &

So that, no need to keep open CMD console.

we would like to know, is there any similar feature available in Windows OS.

please advice.
0
Comment
Question by:mac_g
  • 3
  • 2
5 Comments
 
LVL 15

Assisted Solution

by:ZabagaR
ZabagaR earned 500 total points
ID: 40010350
You could run it silently by calling your .bat from a small .vbs script first.  This Run method allows you to run a batch script in invisible mode. Create a .vbs file like this one. For instance save this as mytest.vbs

Put your .bat file in the below script. I used "mybat.bat" as an example. When you run mytest.vbs it will silently run mybat.bat without a dos window. You could manually run mytest.vbs or use windows task scheduler to run it automatically at a given time

After running, open windows task manager and you'll see "cmd.exe" running your process.

The .vbs script:

Set WinScriptHost = CreateObject("WScript.Shell")
WinScriptHost.Run Chr(34) & "C:\mybat.bat" & Chr(34), 0
Set WinScriptHost = Nothing
0
 

Author Comment

by:mac_g
ID: 40011005
any more advise ....
0
 
LVL 15

Assisted Solution

by:ZabagaR
ZabagaR earned 500 total points
ID: 40011385
From me? No, the above script is a good solution.
0
 

Author Comment

by:mac_g
ID: 40012112
please advice ,....

I want to run this below script..

C:\Oracle\FR\user_projects\domains\ClassicDomain\bin\startWebLogic.cmd

1) how to custmoise above your script
2) how to run this script


Thanks for your help so faar
0
 
LVL 15

Accepted Solution

by:
ZabagaR earned 500 total points
ID: 40012850
You only have to replace my sample bat file with yours.

copy and paste this text below into windows notepad. save it as weblogic.vbs
When you run/double-click it, your .cmd will run silently:


Set WinScriptHost = CreateObject("WScript.Shell")
WinScriptHost.Run Chr(34) & "C:\Oracle\FR\user_projects\domains\ClassicDomain\bin\startWebLogic.cmd" & Chr(34), 0
Set WinScriptHost = Nothing
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A safe way to clean winsxs folder from your windows server 2008 R2 editions
In this article, I will show you HOW TO: Install VMware Tools for Windows on a VMware Windows virtual machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, using the VMware Host Client. The virtual machine has Windows Server 2016 instal…
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now