Reputation: 149
I have a .bat that needs to run as admin although this creates problems with parts of the .bat when %userprofile%
is used it will navigate to system32 rather than the userprofile that the .bat is run on.
I don't have any need to navigate to system32 with the .bat so if there was a way to correct this from the start of the .bat so following commands could be run as the currently logged in user.
Upvotes: 0
Views: 1834
Reputation: 6669
You have two choices:
cd /d "%userprofile%"
or
pushd "%userprofile%"
Upvotes: 1
Reputation: 149
I found the issue seems to be how the .bat is being used (through LogMeIn) for some reason it was going to system32 even using the pushd /d "%userprofile%"
command I found a workaround that works with logmein is the following
pushd "%~dp0"
cd..
cd..
cd..
cd..
Upvotes: 0