1
In the case of prompt
command we can use Windows environment variables to advance paths, such as:
echo %homedrive%
Which will result in the attribute letter where the sistema operacional
was installed.
But to tell you the truth, I never thought I’d need to know where Batch was running from as long as he got the right one. What I want is to prevent the Script to be run by the user accessing another machine (mapped drive) or direct 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
)
I think it might help: https://stackoverflow.com/a/24101703/4713574
– Rovann Linhalis
I took a good look at it, but it’s not really what I need.
– OldSchool
I thought I could run the script on secondary partitions for example, then I would have to check if the drive being run is of the type
Local Fixed Disk
independent of the letter or if it is in the same unit of the OS. But its solution is suitable, very good.– Rovann Linhalis