You can not directly use VBScript constants nor code in batch files; you need to explicitly define the values of the desired constants and create a .VBS file separated from the .BAT one. However, there is another programming language similar to VBScript in several aspects, called JScript, that can be used in the same Batch .BAT file via a simple trick; you just need to enclose the Batch code between these lines:
@set @x=0 /*
rem End of Batch section */
... and place the JScript code at end of the file. For example:
@set @x=0 /*
@echo off
color 0a
cls
echo Hi %USERNAME%
pause >nul
rem Define some useful constants
set /A vbYes=6, vbNo=7
rem Execute *this same* Batch file as a JScript one
cscript //nologo //E:JScript "%~F0"
if %errorlevel% == %vbYes% (
echo Hello2 = Yes
) else (
echo Hello1 = No
)
pause >nul
exit
rem End of Batch section */
// Start of JScript section
// Usage of Popup method: .Popup(strText,[nSecondsToWait],[strTitle],[nType])
var WshShell = WScript.CreateObject("WScript.Shell");
WScript.Quit(WshShell.Popup("Hello",0,"Hi bruh",4+16));
Many facilities available in VBScript are very similar that those in JScript and just differ in details. For example, the VBScript msgbox
is called Popup method in JScript, so the conversion of short code sections from one language to the other one should have no problems...