@echo off to turn off Echo, otherwise commands in the script are output, and only the results are displayed when closed.
Setlocal enabledelayedexpansion need to be used for variable expansion in the For loop
copy/y Mstsc.cmd%systemroot%\ Copy the file to the C:\windows directory
REGEDIT.EXE/S Mstsc.reg Register Boot entry
Taskkill/im explorer.exe/f Kill Desktop Process
Start/wait Newip.cmd starts a new thread in the main process and waits for it to end
Start/wait iexplore.exe http://wakeup.com:8080/wol start IE browser, process remote wake up
Start/wait mstsc.exe/f/multimon/public/v:%ip% to start a remote connection
Hello, Echo! Output shows a word
Ping 127.0.0.1-n 6 > nul delayed execution for 6 seconds
To set the window size and font color:
Color 0a
MODE con:cols=100 lines=20
Mstsc.exe/? Help documentation
Customize the options and decide based on the results:
Choice/ C yn/m "Input y means replace IP, input n means keep the original IP"
If%errorlevel%==1 (set/p ip= Please enter a new IP address:
Echo!ip! > C:\windows\ip.txt
)
Read the contents of the file:
for/f%%i in (C:\windows\ip.txt) do (
Set ip=%%i
)
Kill off a process:
for/f "tokens=2"%%a in (' tasklist/v/fi "windowtitle eq prob-prob.cmd" ') Do (
Set Pid=%%a
)
Taskkill/pid%pid%
How to detect if you can ping with other machines:
Set flag=0
for/f "tokens=4,4 delims=" %%a in (' Ping-n 1%ip%^|find ' reply ' ^|sort/r ') do (
If "%%a" equ "Byte =32" (set flag=1)
)
if%flag% = = 1 (
Start/wait Alreadystart.cmd
Goto MSTSC
) Else (
Start/wait Shouldstart.cmd
Goto WEB
)
How to request administrator permissions:
>nul 2>&1 "%systemroot%\system32\cacls.exe" "%SystemRoot%\System32\Config\SYSTEM"
If '%errorlevel% ' NEQ ' 0 ' (
Echo Request Administrator Permissions ...
Goto Uacprompt
)
: uacprompt
echo Set UAC = createobject^ ("shell.application" ^) > "%temp%\getadmin.vbs"
Echo UAC. ShellExecute "%~s0", "", "", "RunAs", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
Exit/b
Windows Batch program Bat