VBScript runs successfully when executed from SAS Base, but doesn't work in batch mode (I cannot see any errors).
DATA _NULL_;
RC=SLEEP(5);
RUN;
option noxwait;
option noxsync ;
data _NULL_;
rc1=system('path\copy_cal.vbs');
put rc1;
run;
DATA _NULL_;
RC=SLEEP(5);
RUN;
Check the XCMD SAS system option in batch mode to confirm if SAS will let you execute commands in the OS or not:
proc options option = xcmd;
run;
Thank you for your response! 🙂 I have checked the XCMD SAS system option in batch mode, and it shows that it is enabled. There are no errors in the log, and everything appears to be working fine. However, the VBScript code still does not seem to execute.
XCMD Enables the X command in SAS.
NOTE: PROCEDURE OPTIONS used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
65
66 option noxwait nosyntaxcheck;
67 option noxsync ;
68
69 data _NULL_;
70 rc1=system('G:\path\script.vbs');
71 put rc1;
72 run;
0
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
73
74 proc options option=xcmd;
75 run;
SAS (r) Program 9.4 TS1M3
XCMD Enables the X command in SAS.
NOTE: PROCEDURE OPTIONS used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
Just as a thought: The vbs script executes as a child process of your parent SAS session. When running in batch and the parent SAS session terminates the child session will get killed if not finished already.
To test the theory: Use options XWAIT and XSYNC and see if this changes things.
Thank you! but I already have those options added 😕
@laika_matias wrote:
Thank you! but I already have those options added 😕
So the SAS log you shared with us is not what you executed? As in the log it's NOxwait and NOxsync
I've just tried to execute the code according to the options you provided, but still nothing 😕
It seems that the 'xwait' option is causing the SAS application to hang while executing its task.
What OS are you running on?
Maybe just to separate the SAS stuff from the VBS script try just running a single command, like:
options noxwait xsync ; data _NULL_; rc1=system('/*run some command here to make a directory or a file*/'); put rc1; run;
You also might try using SYSTASK, something like:
systask command "/*your command here*/" status=mystatus wait shell; %put &=mystatus &=sysrc; *both should be 0 if success;
What exactly does "when executed from SAS Base" mean?
@laika_matias wrote:
VBScript runs successfully when executed from SAS Base, but doesn't work in batch mode (I cannot see any errors).
DATA _NULL_;
RC=SLEEP(5);
RUN;option noxwait;
option noxsync ;
data _NULL_;
rc1=system('path\copy_cal.vbs');
put rc1;
run;DATA _NULL_;
RC=SLEEP(5);
RUN;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.