Loading... <blockquote><font color="#c24f4a"><b>记录一下自己平时用到的脚本代码,方便以后需要陆收搜集中~~</b></font></blockquote><h2><b><font color="#f9963b">用户权限判断</font></b></h2><p>判断当前用户是否为管理员,然后执行下一步</p><pre><code>@echo off net user guest /active:yes>nul 2>nul set a=%errorlevel% if /i %a% EQU 0 goto :1 if /i %a% EQU 5 goto :2 :2 mshta javascript:window.alert("%a%----现用户为普通权限-----%a%");window.close() exit :1 net user guest /active:no>nul 2>nul mshta javascript:window.alert("%a%---现用户为管理员权限---%a%");window.close() exit</code></pre><h2><b><font color="#f9963b">输入对应数值,做相应命令</font></b></h2><pre><code>@echo off set /p xuanze=是否继续?(Y/N): if /i "%xuanze%"=="Y" goto next if /i "%xuanze%"=="N" goto cd :next echo yes :cd echo no</code></pre><h2><b><font color="#f9963b">PING命令</font></b></h2><p>延迟执行,bat本身不支持延时执行,可以利用PING方式来实现延迟方式,5秒后执行下一条命令</p><pre><code>ping 127.0.0.1 -n 5 >nul</code></pre><p>若PING不通执行相应命令</p><pre><code>ping kms.rastarit.com | find "检查中..." > NUL && goto fail :fail</code></pre><p><br></p><h2><b><font color="#f9963b">检测指定程序不运行则运行1.txt</font></b></h2><pre><code>@echo off :open set "taskname=qq.exe" tasklist |find "%taskname%" /i if "%errorlevel%"=="1" goto str goto ec :str cls echo. "C:\1.txt" exit :ec echo. echo.%taskname%正在运行中... ping 127.0.0.1 -n 10 >nul cls echo:正在检测,请勿关闭本窗口... goto open</code></pre><h2><font color="#f9963b" style="">将文本复制至剪贴板</font></h2><p>新建一个1.TXT文档,将要复制的内容输入进去保存。随后新建一个BAT,将下面代码输入进去即可,txt与bat文件要在同一目录下</p><pre><code>echo off echo im.rastargame.com>serverip.txt clip < serverip.txt echo 复制成功 exit</code></pre><h2><b><font color="#f9963b">根</font></b><b style="background-color: rgb(255, 255, 255);"><font color="#f9963b">令</font></b><b><font color="#f9963b">据当前系统版本执行相应命</font></b></h2><pre><code>@echo off ver | find "6.0." > NUL && goto winvista ver | find "6.1." > NUL && goto win7 ver | find "6.2." > NUL && goto win8 ver | find "6.3." > NUL && goto win81 ver | find "10.0." > NUL && goto win10 :winvista 当前系统为 Vista :win7 当前系统为 Windows 7 :win8 当前系统为 Windows 8 :win81 当前系统为 Windows 8.1 :win10 当前系统为 Windows 10</code></pre><h2><span style="background-color: rgb(238, 236, 224);"><font color="#f9963b"><b>关闭IE代理</b></font></span></h2><pre><code>echo 关闭代理 reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f echo. echo 删除代理IP地址 reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /f echo. echo 关闭“自动配制脚本”(地址也被删除) reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v AutoConfigURL /f echo. echo 开启IE“自动检查设置” reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections" /v DefaultConnectionSettings /t REG_BINARY /d 46000000020000000900 /f echo.</code></pre><h2><b style="background-color: rgb(238, 236, 224);"><font color="#f9963b">设置网络IP为自动获取</font></b></h2><pre><code>:win7 echo. echo 正在自动获取IP地址.... netsh interface ip set address name = "本地连接" source = dhcp netsh interface ip set address name = "无线网络连接" source = dhcp echo 正在自动获取DNS服务器.... netsh interface ip set dns name = "本地连接" source = dhcp netsh interface ip set dns name = "无线网络连接" source = dhcp ipconfig /flushdns gpupdate /force goto show :win10 echo 正在自动获取IP地址.... netsh interface ip set address name = "以太网" source = dhcp netsh interface ip set address name = "WLAN" source = dhcp echo 正在自动获取DNS服务器.... netsh interface ip set dns name = "以太网" source = dhcp netsh interface ip set dns name = "WLAN" source = dhcp ipconfig /flushdns gpupdate /force</code></pre><h2><b><font color="#f9963b">给指定程序创建桌面快捷方式</font></b></h2><pre><code>@echo off echo 正在创建桌面快捷方式,请勿关闭本窗口. echo. echo 如遇杀毒软件拦截,请点击“允许运行” ::设置程序或文件的完整路径(必填)########### set Program="C:\Program Files\Adobe\Adobe After Effects CC 2018\Support Files\AfterFX.exe" ::########设置快捷方式名称(必填)######### set LnkName=Adobe After Effects CC 2018 ::########设置程序的工作路径,一般为程序主目录,此项若留空,脚本将自行分析路径 ####### set WorkDir="C:\Program Files\Adobe\Adobe After Effects CC 2018\Support Files\" ::设置鼠标停留在快捷方式时显示的说明(可选) set Desc=疯子 ::调用VBS脚本 if not defined WorkDir call:GetWorkDir ""%Program%"" (echo Set WshShell=CreateObject("WScript.Shell"^) echo strDesKtop=WshShell.SpecialFolders("DesKtop"^) echo Set oShellLink=WshShell.CreateShortcut(strDesKtop^&"\%LnkName%.lnk"^) echo oShellLink.TargetPath=""%Program%"" echo oShellLink.WorkingDirectory=""%WorkDir%"" echo oShellLink.WindowStyle=1 echo oShellLink.Description="%Desc%" echo oShellLink.Save)>makelnk.vbs echo. makelnk.vbs del /f /q makelnk.vbs echo 桌面快捷方式创建成功! echo. pause exit goto :eof :GetWorkDir set WorkDir=%~dp1 set WorkDir=%WorkDir:~,-1% goto :eof pause exit</code></pre><h2><b><font color="#f9963b">修改文件权限</font></b></h2><pre><code>echo 正在修改360极速浏览器用户权限 cacls.exe C:\Progra~1\360Chrome\Chrome\Application\360chrome.exe /t /e /c /g users:r cacls.exe C:\Progra~1\360Chrome\Chrome\Application\11.0.2052.0 /t /e /c /g users:r cacls.exe C:\Progra~1\360Chrome\Chrome\Application\wow_helper.exe /t /e /c /g users:r<br></code></pre><p>“/t”表示修改文件夹及子文件夹中所有文件的ACL</p><p>“/e”表示仅做编辑工作而不替换</p><p>“/c”表示在出现拒绝访问错误时继续</p><p>“/g users:f”表示给予本地用户users以完全控制的权限,</p><p>“f”代表完全控制</p><p>“r” 给予读取权限</p><h2><b><font color="#f9963b">获取本机IP地址与主机名</font></b></h2><pre><code>@echo off for /f "tokens=4" %%a in ('route print^|findstr 0.0.0.0.*0.0.0.0') do ( set IP=%%a ) echo 本机资产编号为: echo %computername% echo —— echo 本机IP地址为: echo %IP% pause>nul</code></pre><h2><font color="#f9963b">打开、关闭屏幕</font></h2><p>打开</p><pre><code>powershell (Add-Type '[DllImport(\"user32.dll\")]^public static extern void mouse_event(uint dwFlags, int dx, int dy, uint dwData, int dwExtraInfo);' -Name user32 -PassThru)::mouse_event(1,40,0,0,0)</code></pre><p>关闭</p><pre><code>powershell (Add-Type '[DllImport(\"user32.dll\")]^public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);' -Name a -Pas)::SendMessage(-1,0x0112,0xF170,2)</code></pre><h2><font color="#f9963b">检测是否存在文件</font></h2><pre><code>echo 正在检测是否已存在安装包 if not exist "D:\Rastar_IT\Acrobat DC.rar" goto nofile goto start :nofile echo 存在 :start echo 不存在</code></pre><p><br></p><p><br></p><p><br></p><p><br></p> Last modification:March 25, 2020 © Allow specification reprint Like 请我喝肥宅快乐水