|
Answer» Hi. I'm TRYING to call a batch file from another batch, both scripts are in the same folder, but the first one to run is called from a scheduled task, in a remote computer, and the location of scripts may vary depend on many factors.
I've tried SIMPLY "CALL myscript.cmd" without path, but isn't running. It run if I run the first script from the prompt, but not when is called remotely by the task.
I need to know if there is a way to retrieve the 'running path' of a script (like app.path in VB)
I can't pass it as parameter, because there are many scheduled tasks already, calling the first script, and i can't change all of them.
thx. show your code, and how you called the batch remotely.The first script runs from a windows scheduled task, using:
"\\srvname\sharedfolder\script\firstscript.cmd"
I'm replacing several lines of many scripts, changing all the var setting, placing it in a second script, common for all. For that, i need that all the scripts execute a script called var.cmd, practically in the first LINE.
var.cmd is in the same folder than firstscript.cmd
i can't hardcode anything in firstscript.cmd, the folder where the scripts are may vary, and i need to avoid to change anything from the scheduled tasks.
In short, i simply need to run this line in my script:
CALL var.cmd
But, i don't know where var.cmd is, i only know that both scripts are in the same folder. CALL var.cmd, without path works fine if i LAUNCH it from prompt locally, but doesn't from the task, maybe the unc path has something to do.
For that, i think that if i can retrieve the working path in the first script, i can use it when calling the second script.
do i explain myself? or is it more confused now?
FINALLY FOUND IT!
%~p0
I always use it as: %~p1 ; %~p2 ; %~pX, with PARAMETERS...but never realized that 0 means the script itself.
%~n0 works the same way, with the name of the script.
Thanks anyway
|