How could a batch file be included into a batch script that already has a main subroutine? Is there a limit to how many subroutines there can be?
this command calls the ShutDwnCnt1.bat and passes 2 variables to the ShutDwnCnt1.bat batch script.
start C:\Users\%username%\Documents\MyScripts\ShutDwnCnt1.bat %cpuname% %var1%
ShutDwnCnt1.bat file consists of the following code:
Code: Select all
@ECHO OFF
title Shutdown %cpuname% --^> %var1% Timer!!
@ECHO OFF & setlocal enabledelayedexpansion
set "StatusBar=* 4 * * * * * * * * * * * * 3 * * * * * * * * * * * * * * * 2 * * * * * * * * * * * * * * 1 * * * * * * Rebooting...0"
set /a count=0
:cycle
cls
set /A count+=1
SET "progressbar=!StatusBar:~0,%count%!"
set /a myCount=118-%count%
:: echo %count% %progressbar%
echo %mycount% %progressbar%
ping -n 3 127.0.0.1 > nul 2>&1
if %count% NEQ 118 goto :cycle
exit
Main Program Consists of the following:
Code: Select all
:01BeginRDP
Echo Press Any Key to Begin RDP to Machines Online.
echo.
pause
for /f "tokens=1-4 delims=. " %%a in (C:\Users\%UserName%\Documents\MyScripts\AliveIP.txt) do (
set var1=%%a.%%b.%%c.%%d
echo Calling Client Station: %var1%
ping -n 1 %var1% | find "Reply from" & call :1Routine %1
)
echo Sys Admin RDP Session Completed.
pause
exit
:1Routine %1
. . .. instruction1
. . .. instruction2
. . .. instruction3
. . .etc
shutdown /r /m \\%var1% /t 240 /f /c "Sys Admin to connect Remotely. Computer needs Software Maintenance. Save your work. Sys Admin Thanks You!" > C:\Users\%UserName%\Documents\MyScripts\shtdwnErrorSession.txt 2>&1 & start C:\Users\%username%\Documents\MyScripts\ShutDwnCnt1.bat %cpuname% %var1%
. . .. more instruction. . .
exit /b