1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| @Echo OFF
Title Position du CMD
REM ===== Header ====================================
REM == MUST BE AT The Begining of The Batch =========
IF "%~1" == "RestartedByVBS" Goto :Code
REM Create the VBScript, if not exist
IF NOT EXIST "%~DP0pos.vbs" (
(FOR /F "tokens=1*" %%a in ('findstr "^VBS:" ^< "%~F0"') do (
echo(%%b
)) > "%~DP0pos.vbs"
)
REM Start "" "%~DP0pos.vbs" "%~F0" 350 350
Cscript //nologo "%~DP0pos.vbs" "%~F0" 700 400
EXIT /B
REM ===== Code ======================================
REM == Put All Your Code Down Here ==================
:Code
Echo This is a Test Batch File in 700,400 Coordinates on the screen
Pause
Exit /B
REM ===== Position Script============================
:Pos <BatchFileName> <X_Coordinate> <Y_Coordinate>
REM This Function will take three inputs: the name of the Batch file to execute
REM and the X and Y Coordinates to Position its CMD window
VBS: Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
VBS: Set objConfig = objWMIService.Get("Win32_ProcessStartup")
VBS: objConfig.SpawnInstance_
VBS: objConfig.X = WScript.Arguments(1)
VBS: objConfig.Y = WScript.Arguments(2)
VBS: Set objNewProcess = objWMIService.Get("Win32_Process")
VBS: intReturn = objNewProcess.Create( chr(34) & WScript.Arguments(0) &chr(34)& " RestartedByVBS", Null, objConfig, intProcessID)
REM ===== End of VBScript============================ |
Partager