Re: Scheduled script problem



On Nov 15, 11:15 pm, "dk" <kaa...@xxxxxxxxxxx> wrote:
Here is the problem:
A vbs script that sets up a command to run a batch file, calls EXEC on the
command. When run from a scheduled task, it hangs on the EXEC command,
until the scheduler stops the script after the maximum allowed time to run.
If the EXEC command is commented out, the script does some other work and
completes.
The scheduled task is set to run with user permissions set explicitly for
this type of task. When the same user logs in directly and executes the
script from the command line, the batch file and vbs script completes
without problem. User has rights to run and read write in the directory
where the script resides. The user has rights to run the batch file in the
directory where the batch file resides. The user has rights to create files
at root of C: where a process the batch file kicks off wants to write.
Again, works successfully when run from the command line: cscript (or
wscript) EXAMPLENAME.VBS

Any ideas what could be wrong?

Example of what the script is doing:
Dim oShell
dim logFile
set outerFSO = CreateObject("Scripting.FileSystemObject")
set logFile = outerFSO.OpenTextFile("c:\tmp\runreport.log", 2, true)
logFile.WriteLine("Log file created")
Set oShell = CreateObject("WScript.Shell")
strPath = Chr(34) & "C:\Program Files\product name\reports\runreport.bat" &
Chr(34) & " " & Chr(34) & CreateYesterdayName & Chr(34) & " >
c:\tmp\temp.txt"
logFile.WriteLine(strPath)
oShell.exec strPath
logFile.WriteLine("Exiting script")

CreateYesterdayName is a function that creates the desired file name.

Thank you,
D.

Did you specify that the script is to run Interactive? The Exec
command needs a command console, which is not possible if the
operation does not run interactive. In addition, as I understand it,
unless a user is logged in to the workstation such interactive
operations still will fail.

The correct approach, I think, is to replace the Exec with a Run with
it's operation 'hidden', something like this ...

oShell.Run strPath, 0, true

If you want to catch the return code for your log function, try
this ...

Dim nRes
nRes = oShell.Run strPath, 0, true
logFile.WriteLine "Exiting script with exit code: " & nRes

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
.



Relevant Pages

  • Re: log off command
    ... I simply execute the batch file and let them play... ... If it's by the hour you don't need a script. ... You can logoff a sessionname or a session ID in each case you have to ... Is it possible to issue the command from user1's logon to logoff ...
    (microsoft.public.windowsxp.basics)
  • Re: log off command
    ... I simply execute the batch file and let them play... ... If it's by the hour you don't need a script. ... You can logoff a sessionname or a session ID in each case you have to ... Is it possible to issue the command from user1's logon to logoff ...
    (microsoft.public.windowsxp.basics)
  • Re: Command or setting to force monitor on?
    ... Keystrokes vbs script? ... But the same symptoms as without cscript, monitor not waking up, when I ... I set up a batch file containing the commands to first start IE, ... could move to the keystrokes command. ...
    (microsoft.public.windowsxp.general)
  • Re: Scheduled script problem
    ... A vbs script that sets up a command to run a batch file, calls EXEC on the ... until the scheduler stops the script after the maximum allowed time to run. ...
    (microsoft.public.windows.server.scripting)
  • Re: how do you get a handle to the interpreter?
    ... > launch it from the tcl script via exec, rather than creating it as a tcl ... > made into a command ... Umm, if you are launching it via exec it is a complely different process, ...
    (comp.lang.tcl)