Reputation: 151
I know from a desktop I can have a bat file that runs an executable with specific parameters and starts in the same path on the network where the executable exists, but how can I accomplish the same thing when calling the bat file assuming is in same folder as executable from another application?
For example: \My-Network\app\PR8.exe /noload
I want to start specifically in \My-Network\app (same folder where PR8.exe exists) but not where it defaults to which seems to be c:\windows somehow. I can't seem to do a cd on a UNC path and I don't want to use any path letters as the application also detects as to which server it is executing from as well.
Upvotes: 0
Views: 952
Reputation: 7700
It isn't possible to set a UNC working directory for Windows batch files without network mapping drives. However, in Windows 2000 and later, you can use the PUSHD
and POPD
commands to change the working directory to a UNC share when running your script.
Wikipedia gives us the example of creating a shortcut to your batch file where the Target
is set to the following:
%COMSPEC% /E:ON /C "PUSHD """\\My-Network\app\""" & C:\PATH\TO\BATCHFILE.BAT & POPD"
In this case the Working directory attribute of the shortcut is ignored, as the PUSHD
and POPD
commands will change it to the path specified.
Upvotes: 1