One word more about this topic.
It is not possible to avoid that others have access to your Batch file; however, if you want to avoid that others can review the Batch file contents (so they can't modify any part of it) then there are several ways to do that including converting the file to .exe format, although no one of these methods gives complete protection against determined users.
The point here is to use a method simple enough for you, so you may implement it with no problems, but complex enough for others so it dissuade your users to try to break it. I propose a solution based on the Encode procedure for JScript source programs that is not a widely known method, so it may even gives protection against advanced users that have not the appropriate information about it. Here it is:
@if (@CodeSection == @Batch) @then
@echo off
setlocal DisableDelayedExpansion
REM Obfuscate.bat: Obfuscate Batch files
REM Antonio Perez Ayala
if "%~1" equ "" echo Usage: Obfuscate filename.bat & goto :EOF
if not exist "%~1" echo File not found: "%~1" & goto :EOF
set "at=@"
set "pass=%random%"
(
echo %at%if (@Pass == @X%pass%^) @begin
echo @echo off
echo CScript //nologo //E:JScript.Encode "%%~F0" ^> %pass%.bat
echo call %pass%
echo del %pass%.bat
echo exit /B
echo %at%end
echo //**Start Encode**
echo var a = new Array(^);
set "i=0"
for /F "usebackq delims=" %%a in ("%~1") do (
set /A i+=1
set "line=%%a"
setlocal EnableDelayedExpansion
echo a[!i!] = '!line:'=\x27!';
endlocal
)
setlocal EnableDelayedExpansion
echo for ( var i=1; i^<=!i!; ++i ^) WScript.Stdout.WriteLine(a[i]^);
) > "%~N1.tmp"
CScript //nologo //E:JScript "%~F0" "%~N1.tmp"
del "%~N1.tmp"
goto :EOF
@end
// Encode a JScript source file
// Antonio Perez Ayala
var fileToEncode = WScript.Arguments(0);
// Read the source file
var oFSO = WScript.CreateObject("Scripting.FileSystemObject");
var oFile = oFSO.GetFile(fileToEncode);
var oStream = oFile.OpenAsTextStream(1);
var sSourceFile = oStream.ReadAll();
oStream.Close();
// Encode the file
var oEncoder = WScript.CreateObject("Scripting.Encoder");
var sDest = oEncoder.EncodeScriptFile(".js",sSourceFile,0,"")
// Write the encoded version
var sFileOut = fileToEncode.slice(0,-3)+"obf.bat";
var oEncFile = oFSO.CreateTextFile(sFileOut);
oEncFile.Write(sDest);
oEncFile.Close();
Copy this program as Obfuscate.bat and use it giving your Batch file in the parameter; after that, a new file with .obf.bat extension is created that works in the same way than the original file, but with its contents encoded in an unreadable way. For example:
C:\> type test.bat
@echo off
echo Hello World
C:\> Obfuscate test.bat
C:\> type test.obf.bat
@if (@Pass == @X20203) @begin
@echo off
CScript //nologo //E:JScript.Encode "%~F0" > 20203.bat
call 20203
del 20203.bat
exit /B
@end
//**Start Encode**#@~^kQAAAA==@#@&\CMPmP',x⌂APzD.lH`bI@#@&l]qT,'PE@$nm4W,WW0vI@#
@&C$yDP{Pvn1tW~u⌂VsW, KDs9Bp@#@&6WM~`,\CD,kxqpPk@!x pP_3r~#,⌂Um.k2Oc?ONK;Yc⌂.r
D+SrU⌂`C$bD*i@#@&kiYAAA==^#~@
C:\> test.obf.bat
Hello World
I tested this method in Windows XP and Windows 8.