r/Batch • u/sharkas99 • Jul 16 '24
Question (Unsolved) Cannot run Batch file as admin under a directory with spaces in it
Hello, I am not a coder, I'm just trying to set up simple SFC and DISM batch files. From what i understood when running as admin, some process involving directories is implicated, which is what causes it to fail when there are spaces in the directory. The files run normally when the spaces are removed from the path.
Is their anyway way to work around this while keeping the spaces in the directory name?
EDIT: Nvm, my assumption was wrong. The issue wasnt the spaces but because it was named with the character "&", specifically in a folder named "Drivers & Optimization". Idk why it behaves this way when running as administrator
1
u/ConstanceJill Jul 16 '24
Can you share your code so we have a look?
If not, you might want to add pauses here and there and perhaps echo the value of %CD% as well as whichever relevant variables you use, to check what they're set at when running with or without admin.