0

I have a script that makes other scripts run using the start command.

For instance:

start example.bat

It works fine when I don't run it as an administrator, however, when I do, the script says that it can't find the script it's supposed to run.

In this case, when I want to run the same example.bat but instead running the current script in administrator mode, I get an error that says Windows can't find "example.bat", even though I've changed nothing besides running it in admin.

Why's that, and how can I fix it? I would like the script that it is running to also run as an administrator too.

  • `start` is not the same thing as `cmd.exe /k`. It resets the current working directory, for example - which is probably why it's complaining about being unable to find a non-fully-qualified filename. – Dai Nov 29 '20 at 03:41
  • When you run it 'As administrator' the current directory becomes `C:\Windows\System32`. Your script should therefore define your working directory first, or include the paths of the individual batch files instead of just their names. If they're all in the same directory as the master/running batch file, then you can use, for example, `cd /d "%~dp0"`, at the top, or use paths like this, `"%~dp0example.bat"`. I would also suggest that you do not use `start` at all, either just remove it, or replace it with `call` instead. – Compo Nov 29 '20 at 03:51

0 Answers0