Solved

How do I get a scheduled task not to pop up the command window

Posted on 2011-09-13
3
360 Views
Last Modified: 2012-05-12
I am attempting to create a batch file that creates a scheduled task that runs every fifteen minutes.  It creates the task but every fifteen minutes it prompts a cmd window.  How do I get rid the task to run in the background?
0
Comment
Question by:daOracle
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
joeyfaz earned 500 total points
ID: 36532840
You can make the task scheduler run a shortcut to the batch file and then configure the shortcut to run minimized or the other option is to have a vbs script execute it silently:

Set WshShell = CreateObject("WScript.Shell")
runThis=WshShell.RUN("c:\mybatch.bat", 0, True)
Set WshShell = Nothing

Then have the task scheduler execute the runthis.vbs file
0
 

Assisted Solution

by:daOracle
daOracle earned 0 total points
ID: 36537981
I have add the vbs file.  Now it says 0x1.
My batfile looks like this
schtasks.exe /create /tn "DB Maintenance Task" /xml "%dbHome%\data\db\Scripts\DBMaintenanceTask.xml" /RU "NT AUTHORITY\NETWORKSERVICE"



I verified the following:
Check Service settings :
•Open Control Panel, > Administrative Tools > Click Computer Management > Expand Services and Applications > Services.
•Right-click Task Scheduler service > Properties.
•The startup type must be automatic
•The service status must be Started
•Goto Log On tab, select local system account
•Click OK and quit everything
•Reboot the computer and check....
0
 

Author Closing Comment

by:daOracle
ID: 36558807
Awesome!  Thank you very much for you help.  I had to make the following changes to the vbscript.

Switch the network service to SYSTEM
updated the vbscript to get environment variable.
option explicit

DIM WshShell
DIM WsSystemEnv

DIM dbScrLoc

Set WshShell = CreateObject("WScript.Shell")


Set WsSystemEnv= WshShell.Environment("PROCESS")
dbScrLoc="""" & wsSystemEnv("<environment_variable name") + "data\db\Scripts\AMDWSDBMaintenance.bat" & """"
WshShell.run dbScrLoc, 0
Set WshShell = Nothing
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Hi Friends, These registry tweaks will help you optimizing your Windows 7 system for any VDI. This will improve the machine performanance and can be used on normal systems also. These are few registry tweaks which will add value by enhancing the …
A quick guide on how to use Group Policy to create a custom power plan and set it active on Windows 7.
This Micro Tutorial will teach you the basics of configuring your computer to improve its speed. It will also teach you how to disable programs that are running in the background simultaneously. This will be demonstrated using Windows 7 operating…
This Micro Tutorial will teach you how to the overview of Microsoft Security Essentials. This is a free anti-virus software that guards your PC against viruses, spyware, worms, and other malicious software. This will be demonstrated using Windows…

895 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

14 Experts available now in Live!

Get 1:1 Help Now