Question
PowerShell wont work as admin with double quotes
The problem is that the '-Verb RunAs' wont work with '\"' for some reason and I need the quotes for better handeling of paths
:: Check for admin privilage
openfiles > nul 2>&1
if !errorlevel! neq 0 (
echo | set /p="The execution needs elevated privileges (y|n)"
choice /n
if !errorlevel! equ 1 (
start /b /wait PowerShell -Command "Start-Process '%~f0' -ArgumentList '%res% -ico \"%icon%\" -dir \"%directory%\"' %style% -Verb RunAs"
exit /b
)
)
when I remove one of them the other works
::like this
start /b /wait PowerShell -Command "Start-Process '%~f0' -ArgumentList '%res% -ico \"%icon%\" -dir \"%directory%\"' %style%"
::or this
start /b /wait PowerShell -Command "Start-Process '%~f0' -ArgumentList '%res% -ico %icon% -dir %directory%' %style% -Verb RunAs"
Or when I convert it into an executable it works
I don't know why is that happening maybe a glitch or something I hope someone finds a solution