Running a vbs script in task schedule in windows 2008

I have a vbscript which deletes logs after 7 days.  When i run it as cscript logs.vbs, it runs and works.  I now want to setup it to run under a schedule every week, so i would need use task scheduler.  Its on windows 2008 server.   SO how would i schedule this in task scheduler, i have tried few things but when it runs, it does nothing.

DO i need to create a batch file, and just enter the command cscript d:\logs.vbs, or something.

Can anyone please advise how i can get a vbs script to run weekly under task schedule in windows 2008.  The vbs script is saved on a d:\scripts.

 

Thanks 

October 13th, 2011 11:58am

Hi,

My best advice would be to create a batch file to run the .vbs and insert the batch file in the scheduler as required.

Batch file should look like

@echo off 
start c:\xxx.vbs 

 

Best of luck!

Martin

Free Windows Admin Tool Kit Click here and download it now
October 14th, 2011 12:48am

I have a vbscript which deletes logs after 7 days.  When i run it as cscript logs.vbs, it runs and works.  I now want to setup it to run under a schedule every week, so i would need use task scheduler.  Its on windows 2008 server.   SO how would i schedule this in task scheduler, i have tried few things but when it runs, it does nothing.

First of all obtain the "cscript.exe" scripting runtime full pathname (it should be "%systemroot%\system32\cscript.exe"), next, assuming that your script name is "logs.vbs" and that it sits inside "d:\scripts", enter the following command in your scheduled task

%systemroot%\system32\cscript.exe d:\scripts\logs.vbs


also, if the script needs to be executed from "d:\scripts", configure the task to start from such a folder; there's no need to setup a batch script to run such a task, but if you prefer you may write a small wrapper like

@echo off
pushd d:\scripts
cscript logs.vbs
popd
exit


and schedule it in place of the straight "cscript" call

 

October 14th, 2011 8:02am

Hi,

 

I would like to suggest you refer to the following links for how to use Task Scheduler with script:

 

Working with the Windows Server 2008 Task Scheduler (Part 1)

http://www.windowsnetworking.com/articles_tutorials/Working-Windows-Server-2008-Task-Scheduler-Part1.html

 

Working with the Windows Server 2008 Task Scheduler (Part 2)

http://www.windowsnetworking.com/articles_tutorials/Working-Windows-Server-2008-Task-Scheduler-Part2.html

 

In addition, please also, you may submit a new question in The Official Scripting Guys Forum! which is a best resource for scripting related issues.

 

The Official Scripting Guys Forum!

http://social.technet.microsoft.com/Forums/en/ITCG/threads

 

Regards,

Free Windows Admin Tool Kit Click here and download it now
October 17th, 2011 3:00am

Struggled this issue, and followed you instruction it works for me now, thanks

April 13th, 2015 1:39am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics