Re: Scheduling a VBS within a at job by Ray
Ray
Sat Oct 30 12:22:47 CDT 2004
For me, the second one works. The first one does not pass the arguments.
IOW,
at 13:16 c:\scheduled.vbs one two ---> No arguments passed
at 13:16 cscript c:\scheduled.vbs one two --> Arguments passed
Script:
bError = False
On Error Resume Next
Set oArgs = WScript.Arguments
s1 = oArgs(0)
s2 = oArgs(1)
Set oArgs = Nothing
If Err.Number <> 0 Then
S1 = "Error"
S2 = "Error"
End If
Dim oFSO
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFile = oFSO.CreateTextFile("C:\scheduled.txt")
oFile.Writeline "Arg 1: " & s1
oFile.WriteLine "Arg 2: " & s2
oFile.Close : Set oFile = Nothing
Set oFSO = Nothing
Ray at work
"Rui Vilao" <rui.vilao@rocketmail.com> wrote in message
news:385a715f.0410300345.23bb473f@posting.google.com...
> Hi Ray,
>
> Thanks for your suggestion.
>
> In fact my script expects two parameters:
>
>
> at 19:33 [/every...] c:\scheduled.vbs param1 param2
> at 19:34 [/every...] cscript C:\scheduled.vbs param1 param2
>
> May be thats the problem...
>
> TIA
>
> Rui.
>
> "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
> message news:<eCyBq#gvEHA.2016@TK2MSFTNGP15.phx.gbl>...
>> You don't have any Msgbox commands or anything like that in your vbs
>> files,
>> do you? Because if so, the script will sit there waiting forever for
>> someone to click OK, but since AT tasks run under the system account, no
>> one
>> will see the Msgbox or anything.
>>
>> Does your script run okay when you run it yourself?
>>
>> Is it trying to access any network shares or anything?
>>
>> You can schedule .vbs files the way you have here, but instead of
>> scheduled
>> cmd.exe to run, I feel you should either just schedule the .vbs file and
>> let
>> the default script handler run it, or schedule either cscript or wscript
>> to
>> run (preferable cscript since this task will not run in an GUI
>> environment
>> anyway).
>>
>>
>> Example:
>> C:\scheduled.vbs:
>> Dim oFSO
>> Set oFSO = CreateObject("Scripting.FileSystemObject")
>> Set oFile = oFSO.CreateTextFile("C:\scheduled.txt")
>> oFile.Writeline "eakj"
>> oFile.Close : Set oFile = Nothing
>> Set oFSO = Nothing
>>
>>
>> Commands that will work:
>> at 19:33 [/every...] c:\scheduled.vbs
>> at 19:34 [/every...] cscript C:\scheduled.vbs
>>
>> Ray at work
>>
>>
>>
>>
>> "Rui Vilao" <rui.vilao@rocketmail.com> wrote in message
>> news:385a715f.0410291215.482b482@posting.google.com...
>> > Hi all,
>> >
>> > I have created a bat file to schedule automatically a vbs as follow:
>> >
>> > at 01:00 /every:M,T,W,Th,F,S,Su cmd /c "c:\bat\check.vbs"
>> > at 02:00 /every:M,T,W,Th,F,S,Su cmd /c "c:\bat\check.vbs"
>> > at 03:00 /every:M,T,W,Th,F,S,Su cmd /c "c:\bat\check.vbs"
>> > ...
>> >
>> > I works, but when a cmd.exe and wscript.exe keep running within Task
>> > Manager...
>> >
>> > What is the best way to schedule within a batch?
>> >
>> > Any help/suggestion is highly appreciated.
>> >
>> > Thanks in advance for your help,
>> >
>> > Kind Regards,
>> >
>> > Rui Vilao.