In the case of prompt
of command we can use Windows environment variables to advance paths, such as:
echo %homedrive%
That will result in the attribute letter where sistema operacional
was installed.
But to tell you the truth, I never thought of needing to know where Batch would be running as long as it hit the right path. What I want is to prevent the script from being run by the user by accessing another machine (mapped drive) or directly from a pen drive.
IF %HOMEDRIVE% == LOCAL_DA_SCRIPT (
goto INICIAR
) ELSE (
echo NAO PERMITIDO, ENCERRE O SCRIPT OU PECA AJUDA
echo PARA O SUPORTE TECNICO
pause>nul
)