Windows Batch program Bat

Source: Internet
Author: User
Tags mstsc

@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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.