Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Issue with Windows Task Schedular

Reply
 
Old 05-27-2009   #1 (permalink)
Muhammad Nasir Waqar


 
 

Issue with Windows Task Schedular

Dear All,

I want to write a Script for setting up a Windows Task Schedular such that
it runs everyday after 1 hour.

I tried using Sleep but it does not work in Windows Server 2003 environment.
Can anyone suggest me something?

Kind Regards,
Muhammad Nasir Waqar



My System SpecsSystem Spec
Old 05-27-2009   #2 (permalink)
Pegasus [MVP]


 
 

Re: Issue with Windows Task Schedular


"Muhammad Nasir Waqar" <nasir@xxxxxx> wrote in message
news:OHroINq3JHA.1864@xxxxxx
Quote:

> Dear All,
>
> I want to write a Script for setting up a Windows Task Schedular such that
> it runs everyday after 1 hour.
>
> I tried using Sleep but it does not work in Windows Server 2003
> environment. Can anyone suggest me something?
>
> Kind Regards,
> Muhammad Nasir Waqar
The easiest way to create a scheduled task is to use schtasks.exe. If you
wish to automate the process then you could embed schedtask.exe in a batch
file (easy) or invoke it with the Run method in a VB Script (less easy).

The Sleep method works very well under Windows Server 2003. If it does not
work for you then let's have a look at your script.


My System SpecsSystem Spec
Old 05-27-2009   #3 (permalink)
Muhammad Nasir Waqar


 
 

Re: Issue with Windows Task Schedular

I am Sorry for wrong posting.

I intially wrote the following script with help from Microsoft site..

strComputer = "."
Set objService = GetObject("winmgmts:\\" & strComputer)
Set objNewJob = objService.Get("Win32_ScheduledJob")
errJobCreated = objNewJob.Create ("notepad.exe",
"********123000.000000-420", True , 1 , , , JobID)

This script was solving my issue of creating a Scheduled Task but was not
allowing me to run it daily after every hour. Then, I wrote another
following script:

Set WshShell = WScript.CreateObject("WScript.Shell")
i=1
do while i<11
msgbox i
WshShell.Run "notepad.exe"
WshShell.sleep 6000
i=i+1
loop

This script solves my problem but sleep is not working.

Please help.

Kind Regards,
Muhammad Nasir Waqar


"Pegasus [MVP]" <news@xxxxxx> wrote in message
news:enp5Qkq3JHA.4272@xxxxxx
Quote:

>
> "Muhammad Nasir Waqar" <nasir@xxxxxx> wrote in message
> news:OHroINq3JHA.1864@xxxxxx
Quote:

>> Dear All,
>>
>> I want to write a Script for setting up a Windows Task Schedular such
>> that it runs everyday after 1 hour.
>>
>> I tried using Sleep but it does not work in Windows Server 2003
>> environment. Can anyone suggest me something?
>>
>> Kind Regards,
>> Muhammad Nasir Waqar
>
> The easiest way to create a scheduled task is to use schtasks.exe. If you
> wish to automate the process then you could embed schedtask.exe in a batch
> file (easy) or invoke it with the Run method in a VB Script (less easy).
>
> The Sleep method works very well under Windows Server 2003. If it does not
> work for you then let's have a look at your script.
>

My System SpecsSystem Spec
Old 05-27-2009   #4 (permalink)
ekkehard.horner


 
 

Re: Issue with Windows Task Schedular

Muhammad Nasir Waqar schrieb:
Quote:

> I am Sorry for wrong posting.
[...]
Quote:

> Set WshShell = WScript.CreateObject("WScript.Shell")
> i=1
> do while i<11
> msgbox i
> WshShell.Run "notepad.exe"
> WshShell.sleep 6000
WScript.Sleep 6000
Quote:

> i=i+1
> loop
>
> This script solves my problem but sleep is not working.
[...]
My System SpecsSystem Spec
Old 05-27-2009   #5 (permalink)
Muhammad Nasir Waqar


 
 

Re: Issue with Windows Task Schedular

Thanks alot. This solved my problem.

"ekkehard.horner" <ekkehard.horner@xxxxxx> wrote in message
news:4a1d2f8b$0$31332$9b4e6d93@xxxxxx-online.net...
Quote:

> Muhammad Nasir Waqar schrieb:
Quote:

>> I am Sorry for wrong posting.
> [...]
Quote:

>> Set WshShell = WScript.CreateObject("WScript.Shell")
>> i=1
>> do while i<11
>> msgbox i
>> WshShell.Run "notepad.exe"
>> WshShell.sleep 6000
> WScript.Sleep 6000
Quote:

>> i=i+1
>> loop
>>
>> This script solves my problem but sleep is not working.
> [...]

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Configurable Windows Task Schedular .NET General
Task Schedular Software
Task Schedular and Access Vista General
stopping task schedular Vista General
Task Schedular problem Vista performance & maintenance


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46