DOS批处理命令

//批量更名

@echo off&setlocal EnableDelayedExpansion
set a=1
for /f "delims=" %%i in ('dir /b *.txt') do (
if not "%%~ni"=="%~n0" (
if !a! LSS 10 (ren "%%i" "文件名!a!.txt") else ren "%%i" "文件名!a!.txt"
set/a a+=1
)
)
---------------------------------------------------------------------
//批量[复制]或[移动]到其它位置生成新[随即名]文件
@echo off
set num=0
for /f "delims=" %%i in ('dir /a-d /b *.txt') do (
    if not exist "文件夹/%%i" (
        move "%%i" 文件夹/>nul
    ) else call :copy_txt "%%i" "%%~ni" %%~xi
)
goto :eof

:copy_txt
set file_n=%2
set "file_n=%file_n:~1,-1%"
set file_x=%3
set /a num+=1
if not exist "文件夹/%file_n%%num%%file_x%" (
    move %1 "文件夹/%file_n%%num%%file_x%">nul
) else call :copy_txt %1 "%file_n%" %file_x%
set num=0
goto :eof
---------------------------------------------------------------------
//重新启动

echo @echo off >DosRB.bat
echo echo welcome to http:// >>DosRB.bat
echo cd/d ^"%t^e^m^p%^" >>DosRB.bat
echo (echo [version] >>DosRB.bat
echo echo signature=$chicago$ >>DosRB.bat
echo echo [defaultinstall])>reboot.inf >>DosRB.bat
echo set inf=InstallHinfSection DefaultInstall >>DosRB.bat
echo rundll32 setupapi,"%inf%" 1 ^"%t^e^m^p%/reboot.inf^" >>DosRB.bat
echo del reboot.inf >>DosRB.bat

DosRB.bat
---------------------------------------------------------------------
//重新启动

echo debug >DebugRB.bat
echo -a >>DebugRB.bat
echo int 19 >>DebugRB.bat
echo int 20 >>DebugRB.bat
echo -rcx >>DebugRB.bat
echo :2 >>DebugRB.bat
echo -nreset.com >>DebugRB.bat
echo -w >>DebugRB.bat
echo -q >>DebugRB.bat

DebugRB.bat
---------------------------------------------------------------------

//查询终端服务端口

echo Dim ReadComputerName >PORT.vbs
echo Set ReadComputerName^=WScript.CreateObject("WScript.Shell") >>PORT.vbs
echo Dim TSName,TSRegPath >>PORT.vbs
echo TSRegPath="HKLM/System/CurrentControlSet/Control/Terminal Server/WinStations/RDP-Tcp/PortNumber" >>PORT.vbs
echo TSName=ReadComputerName.RegRead(TSRegPath) >>PORT.vbs
echo WScript.Echo("PORT:"^&TSName) >>PORT.vbs

cscript PORT.vbs
---------------------------------------------------------------------
//查看PID

echo wscript.echo "PID     ProcessName">>PID.vbe
echo for each ps in getobject("winmgmts://./root/cimv2:win32_process").instances_ >>PID.vbe
echo wscript.echo ps.handle^&vbtab^&ps.name>>PID.vbe
echo next>>PID.vbe

cscript PID.vbe

//察看终端端口

Dim ReadComputerName
Set ReadComputerName=WScript.CreateObject("WScript.Shell")
Dim TSName,TSRegPath
TSRegPath="HKLM/System/CurrentControlSet/Control/Terminal

Server/WinStations/RDP-Tcp/PortNumber"
TSName=ReadComputerName.RegRead(TSRegPath)
WScript.Echo("终端端口为"&TSName)

把以上代码保存为vbs文件,如“3389port.vbs”
然后在命令行下运行cscript 3389port.vbs 即可查看终端端口(桌面环境下可直
接点击查看)。

 

---------------------------------------------------------------------
//位置

%USERPROFILE%      Documents and Settings/当前登陆用户文件夹
%ProgramFiles%     Program Files
%SystemRoot%       Windows Or WinNT

---------------------------------------------------------------------

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值