Solved

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

Posted on 2011-09-13
3
376 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Command prompt flashing when starting PC 16 90
GPO not being applied to Win7 Pro Image 5 50
Outlook 2010 meeting recurrances 26 15
Need to make video of desktop 5 21
First some basics on Windows 7 Backup.  It has 2 components one is a file based backup which is stored in .zip files each zip is split at around 200 Megabytes and there is the Image Backup which is as the name implies a total image of the partition …
You may have a outside contractor who comes in once a week or seasonal to do some work in your office but you only want to give him access to the programs and files he needs and keep privet all other documents and programs, can you do this on a loca…
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 give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.

821 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