Solved

windows OS: how to run script in background

Posted on 2014-04-19
5
2,090 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
Comment Utility
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
Comment Utility
any more advise ....
0
 
LVL 15

Assisted Solution

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

Author Comment

by:mac_g
Comment Utility
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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
OfficeMate Freezes on login or does not load after login credentials are input.
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…

772 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

11 Experts available now in Live!

Get 1:1 Help Now