Search code examples
batch-filestartup

Batch: move - cant find the path specified (adding bat to startup)


Hey trying to add a bat to my startup folder by executing another bat.

setup.bat

move "run.bat" "%AppData%\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\"
pause

run.bat

echo "k"
pause

if i run this normally the error message says:

The system cannot find the path specified

if its run as admin:

the system cannot find the file specified

?


Solution

  • "%AppData%\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\" doesn't exist as a directory.

    %appdata% expands to C:\Users\Hawk\AppData\Roaming, so you're actually telling the script to go to C:\Users\Hawk\AppData\Roaming\\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\, which doesn't exist.

    Change setup.bat to

    move "run.bat" "%AppData%\Microsoft\Windows\Start Menu\Programs\Startup\"
    pause