I. SchTasks
With SchTasks, we can schedule tasks on the local server or remote server, which is quite useful when we need to automate tasks on multiple servers and reduce tedious work, the batch processing code I used is provided below for your reference:
REM Global variableset logfile=schedule.txtset /p choose=Please choose (1: for "Close Menu for Account", 2: for "Open Menu for Account"):if "%choose%"=="1" goto CLOSE if "%choose%"=="2" goto OPENgoto EXIT:CLOSEecho ... Close Menu for Account ...echo Start schedule at %DATE% %TIME% > %logfile% set schedule_dt=%date:~0,4%/%date:~5,2%/%date:~8,2%echo Default schedule date is %schedule_dt%, Press Enter for accepting it!set /p schedule_dt=[Please input your own schedule date:]for /f "eol='" %%i in (hosts.txt) do ( echo Host: "%%i" is executing schedule ... >> %logfile% schtasks /change /tn "Close_Menu_for_account" /s %%i /u username /p password /sd %schedule_dt% /st 23:00:00 >> %logfile%)goto ENDING:OPENecho ... Open Menu for Account ...echo Start schedule at %DATE% %TIME% > %logfile% for /f "eol='" %%i in (hosts.txt) do ( echo Host: "%%i" is executing schedule ... >> %logfile% schtasks /run /tn "Open_Menu_for_account" /s %%i /u username /p password >> %logfile%):ENDINGecho Finish schedule at %DATE% %TIME% >> %logfile%echo Operation finish:EXITpause
The above code has two functions: 1. Specify multiple servers to execute the set scheduled task at; 2. Execute the set tasks on multiple servers immediately.
Hosts.txt stores the IP addresses of multiple servers. The specific content is as follows:
'Web servers used
192.168.0.1
192.168.0.2
192.168.0.3
2. WebDev. WebServer
WebDev. WebServer is a lightweight Web server built in. NET framework 2.0. It is mainly used as Visual Studio. NET to debug ASP. NET programs. With this feature, we can perform a simple test on the pages we write to view the results.
@echo off:Justify whether the webserver is runningtasklist | find /i "webdev.webserver.exe" >nul 2>nul && goto KILL || goto RUN:KILLtaskkill /f /im "WebDev.WebServer.EXE" >nul 2>nul:RUNREM Suppose the VS2008 in VISTAcd /d C:\Program Files\Common Files\microsoft shared\DevServer\9.0start WebDev.WebServer.EXE /port:7736 /path:"D:\examples\tutorials\js" /vpath:"/"