On SAS Windows, I have a SAS script calling an external .bat file. I use the following:
%SYSEXEC("\\mymachine\order\mypath\running.bat");
which does not recognise the path and default to a C:\ path
if I use - but I would prefer not to - the following
%SYSEXEC("D:\mypath\running.bat");
then it works and my .bat file get executed
any hints on how to use the \mymachine path??
thanks
edits after some comments below; a round about way we just found was to add
pushd "%~dp0"
at the start of the external .bat script - it seem to create a temporary mapped drive pointing to the network path to run the batch.
Reiterating:
From the docs:
Comparisons
The %SYSEXEC statement is analogous to the X statement and the X windowing environment command. However, unlike the X statement and the X windowing environment command, host commands invoked with %SYSEXEC should not be enclosed in quotation marks.
So, %SYSEXEC
is a statement and does not need parenthesis and generally no double quotes either, unless the OS path contains spaces -- in such a case you may experience hair-thinning as you start dealing with "
and SAS double-double quote expressions and potential OS double quote needs within the %SYSEXEC
command shell.
Try the following:
%SYSEXEC NET USE P: \\mymachine\order\mypath
%SYSEXEC P:\running.bat
You can set the active drive and folder of the session with
%SYSEXEC NET USE P: \\mymachine\order\mypath
%SYSEXEC P:
%SYSEXEC CD \
%SYSEXEC .\running.bat
If you are comfortable with your Windows install, you can also use PUSHD
to set the drive and folder in one command.