10-05-2015 10:41 AM
I'm having an issue where if I manually run the VBS file that SAS Enterprise Guide generates for scheduling the project runs perfectly; however, when I schedule the VBS file in Windows Task Scheduler the script does not execute. I see the cscript start in task manager and then it closes as if the project ran but none of the files are extracted and there isn't any informaiton added to the project log.
Can anyone provide a solution to this problem?
10-07-2015 01:13 AM
The problem might be that you do not have the correct user rights when running the script under the task scheduler. You may need to provide your full username (including your user domain) and password to allow the the task scheduler to log in as you when scheduling your schedule.
If it is not simply your user log in then it sounds like your project is encountering an error while it is running. You do not get anything displaying in the project log because nothing is saved unless the script completes successfully. Also, the error being generated does not usually appear in the project log because the error is originating from the commands running in the cscript shell, not the SAS Enterprise Guide application.
If you open the visual basic script that SAS Enterprise Guide creates then you can edit the script to make it produce an error message. This editing can be done in SAS Enterprise Guide or a text editor such as Notepad.
Near the bottom of the script there should be a line that reads:
'MsgBox strmsg 'Uncomment this line if you want to be notified via MessageBox of Errors in the script.
If you remove the single quote and change the line to read:
MsgBox strmsg 'Uncomment this line if you want to be notified via MessageBox of Errors in the script.
Then the script will produce a WINDOWS error message.
How Windows presents any script error message will depend on how Windows runs the script. If the script is run with cscript.exe then it might just appear in the command window that cscript.exe is run from, which may not be visible for long enough after the script finishes. However, if the script is run by wscript.exe then an OK message box will pop up on screen when the script encounters an error. To make this happen you may need to play with the windows task scheduler - if you have the rights to do so.
If the problem is not caused by a log on problem, it could be that Windows is trying to run a 32-bit version of the script when it should be running a 64 bit version, or vice versa. This is where the error messages get more obscure as they may say that the application cannot be found. Depending on your version of windows, and SAS Enterprise Guide, you may need to use either a 32 bit or 64 bit version of cscript.exe to run. Sometimes, the task scheduler only runs the 32 bit version, when you need the 64 bit version. Other times the 64 bit version is being run when you need to run the 32 bit version. Trouble is windows switches between the 32 bit version and the 64 bit version depending on whether your runtime environment is 32 bit or 64 bit and there is no easy way of telling the script that it needs to run in a different environment than the current runtime environment as the runtime commands are the same in both environments as windows does some fancy directory renaming in the background.