Relative path in batch
-
I may be possible to do this via Powershell, and at some point that may be. The point.
But right now, I am trying to prevent people from causing issues going forward with renaming the source folder.
This simple script - Windows Batch file - dos the following;
-Copy shortcut to /users/public/desktop
-Calls install of adobe Reader XI (compatibility issue with newer)
-Calls install of two additional applications.Since I created it, the path to it has been changed twice... Is there a way to set a variable that grabs the path -
ETA:
I many have answered my own question. Generally the folder is access via Explorer, not CMD. As such, I dont think it can grab the path to the file. -
%publicdesktop%
or something like that. -
This post is deleted! -
You want the path to the folder that the script is in? %~dp0
-
@JaredBusch said in Relative path in batch:
%publicdesktop%
or something like that.THat will work for the public desktop - indeed.
-
@flaxking said in Relative path in batch:
You want the path to the folder that the script is in? %~dp0
Yes, And again - it may not really be possible in Batch.. and by path:
\server\share1\sharename2\some othershare\departmentshare(files)
was changed to
\server\share1\sharename2\some othershare\department_share name of something(files)
-
can you show us the script?
I think you just want to replace \server\share1\folder1\folder2\folder3\file to .\file, assuming everything is in that one folder.
-
@Dashrender said in Relative path in batch:
can you show us the script?
I think you just want to replace \server\share1\folder1\folder2\folder3\file to .\file, assuming everything is in that one folder.
Not everything is, but I will give that a shot on the items that are.
-
.\ Won't necessarily refer to the folder the script is in, it will refer to the working directory at the time that the script is launched.
%~dp0 refers to the directory the script is in, but I don't recall if it works for Network shares.
-
@flaxking said in Relative path in batch:
.\ Won't necessarily refer to the folder the script is in, it will refer to the working directory at the time that the script is launched.
%~dp0 refers to the directory the script is in, but I don't recall if it works for Network shares.
Good point. mapped drives would help this, even if you're mapping it long enough for the script to run, then unmapping it at the end.