The problem is that the ‘-Verb RunAs’ wont work with ‘”‘ for some reason
and I need the quotes for better handeling of paths
<code>:: 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
)
)
</code>
<code>:: 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
)
)
</code>
:: 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
<code>::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"
</code>
<code>::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"
</code>
::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 find’s a solution
New contributor
Achraf Benzaria is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.