I've created a batch file for running a setup.exe (code below) but I'm having issues getting the setup.exe to "run as administrator". I used this guide (shortcut trick) for aid.
start "" %CD%\Setup.exe
NOTE: My files will eventually be burnt to a DVD disk. They are currently in the directory "C:\Drivers\win8.1_x64\01a.chipset"
.
The batch file code runs the setup.exe (without admin privileges) fine, when running the batch file by itself (i.e. not running the shortcut).
However, when I run the batch file via the shortcut, Windows gives the error "Windows cannot find 'C:\Windows\system32\Setup.exe'"
.
The setup.exe directory is not in the system32 folder. Why does running the batch file find the setup.exe fine but not when I run it by the shortcut (so I can run the setup.exe as an admin)?
You can either set the working directory in the shortcut itself, or run Setup.exe not from working directory (%CD%
) but from directory where script is located:
start "" "%~dp0\Setup.exe"
Difference from earlier answer is there's no need to cd
to %~dp0
. Just run the setup with full path.
By default admin privileged scripts are starting in C:\Windows\system32\
Try to put cd /d "%~dp0"
at the beginning of your script which should change the work directory to the script's one.You can check this if you want to create a shortcut with admin permissions from the command line.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With