批处理记录

映射盘符与修改卷标:

:On Error Resume Next
:Sub bat
echo off & cls
'&subst X: c:\personalfiles
'&subst W: %windir%
'&subst P: "%ProgramFiles(x86)%"
'&subst A: "%TEMP%"
'&subst B: "%userprofile%"
start wscript -e:vbs "%~f0"
Exit Sub : End Sub
Set oShell = WScript.CreateObject("Shell.Application")
oShell.NameSpace("X:\").Self.Name = "Personal Files"
oShell.NameSpace("W:\").Self.Name = "Windows"
oShell.NameSpace("P:\").Self.Name = "Program Files"
oShell.NameSpace("S:\").Self.Name = "Public"
oShell.NameSpace("T:\").Self.Name = "Team Drive"
oShell.NameSpace("U:\").Self.Name = "User Drive"
oShell.NameSpace("A:\").Self.Name = "Temp Folder"
oShell.NameSpace("B:\").Self.Name = "User Profiles"

域应用

@echo off & rem mode con cols=30 lines=5 &color 84
title 查询用户名或ID的小工具
:start
set "c1="
cls
echo 请选择查询:
echo.
echo    1)机器名   2)用户名ID
echo.
set /p c1=请输入:
if "%c1%" equ "1" goto pc
if "%c1%" equ "2" goto id
goto start
:pc
cls
echo.
echo 请输入机器SN的3+位:
echo.
set "sn="
set /p sn=请输入:
cls
echo.
echo 包含"%sn%"的计算机名有:
echo.
dsquery computer domainroot -o rdn -name "*%sn%*"
pause>nul
goto start

:id
cls
echo.
echo 请输入用户名或ID以查询
echo.
set "no="
set /p no=请输入:
cls
echo.
echo "%no%" 的结果有:
echo.
dsquery user domainroot -o rdn -samid "%no%" & dsquery user domainroot -o samid -name "%no%"
pause>nul
goto start

N年前写的。。。不更正先。

@echo off
:start
cls
SET PACKPATH=%~p0
SET PACKDRV=%~d0
SET PACKDIR=%PACKDRV%%PACKPATH%
echo.
echo.   It's a Tool for IT Onsite.
echo.
echo.   Press No.1 to add printer.
echo.   Press No.2 to add DNS and Proxy.        (need admin)
echo.   Press No.3 to install sogou_wubi.       (need admin)
echo.   Press No.7 to install youdao            (need admin)
echo.   Press No.8 to set timezone to +8
echo.   Press No.9 install sogou_pinyin
::echo. Press No.4 to Join Domain.          (need locadmin)
::echo. Press No.5 to Unjoin Domain.            (need locadmin)
echo.   Apply 1.2.8 press Num.6.                (need admin)
echo.   Press No.0 to exit.
echo.
echo.   Create By KingShui @PHILIPS 03092012
echo.
set num=""
set /P num=Press Num 0-5 to apply:
if "%num%" == "0" goto exit
if "%num%" == "9" goto inputpy
if "%num%" == "8" goto timezone
if "%num%" == "7" goto youdao
if "%num%" == "6" goto printer
::if "%num%" == "5" goto unjoindomain
::if "%num%" == "4" goto joindomain
if "%num%" == "3" goto input
if "%num%" == "2" goto dnsproxy
if "%num%" == "1" goto printer
goto start

:printer
cls
echo Add printer and setting defalut print as Mono...
::it is command list for add printer
set printer=rundll32 printui.dll,PrintUIEntry
set printpc=\\cnhszppdc1ms011\
%printer% /in /n %printpc%CN_PDCC_Mono
%printer% /in /n %printpc%CN_PDCC_Colour
%printer% /y /n %printpc%CN_PDCC_Mono
echo Done!
if "%num%" == "6" goto dnsproxy
goto start

:dnsproxy
echo Adding DNS...
::It's command list for dns
::reg add "HKLM\SYSTEM\CurrentControlSet\services\Tcpip\Parameters" /v SearchList /d code1.emi.philips.com,diamond.philips.com,gdc1.ce.philips.com
echo Windows Registry Editor Version 5.00 > %temp%\sl.reg
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters] >> %temp%\sl.reg
echo "SearchList"="code1.emi.philips.com,diamond.philips.com,gdc1.ce.philips.com" >> %temp%\sl.reg
regedit /s %temp%\sl.reg
del /s/q %temp%\sl.reg
echo Add IE proxy script...
::It's command list for proxy script
reg add "HKU\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v AutoConfigURL /d http://apac.pixs.philips.com:8081/proxy.pac /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v AutoConfigURL /d http://apac.pixs.philips.com:8081/proxy.pac /f
echo Done!
if "%num%" == "6" goto timezone
goto start

:timezone
cls
tzutil /s "China Standard Time"
goto start

:input
::install input type
cls
echo installing sogou_wubi...
start \\cnhszppdc1dt999\Software\lrg\software\sogou_wubi_20a.exe
echo Done!
goto start

:inputpy
::install input type
cls
echo installing sogou_pinyin...
start /wait %PACKDIR%\apps\sogou_pinyin.exe
echo Done!
goto start

:youdao
cls
echo. installing youdao...
start /wait %PACKDIR%\apps\YoudaoDictfull.exe
echo Done!
goto start


:exit
exit

应急的补刀:


@echo off & title Extentions App Installer >nul 2>&1 "%systemroot%\system32\cacls.exe" "%systemroot%\system32\config\system" if '%errorlevel%' NEQ '0' ( goto UACPrompt ) else ( goto gotAdmin ) :UACPrompt echo Set UAC = CreateObject^("Shell.Application"^) > %temp%\getadmin.vbs" echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> %temp%\getadmin.vbs" "%temp%\getadmin.vbs" exit /B :gotAdmin if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" ) if not exist t: net use t: \\sz-fsp1\it if not exist s: net use s: \\sz-fsp1\pub\ pushd "%CD%" cd /d "%~dp0" :main ::set timezone tzutil /s "China Standard Time" ::sync time net time \\sz-fsp1 /set /y echo. echo install fontpack for adobe reader start /w "" s:\it\software\adobe\fontpack\FontPack11000_XtdAlf_Lang.msi /qb echo. echo fontpack installed ::main start ::regedit /s extentionsapps\cn.reg :vpnclient echo uninstalling Old version vpn client... MsiExec.exe /X{AAAB700A-DDB7-4298-AB4B-B6E9F785059C} /q msiexec.exe /X{681ADA0C-597A-4F9B-BFEA-5A54808F292F} /q if not exist "%programfiles(x86)%\Citrix\SelfServicePlugin" (start /w "" "C:\Program Files (x86)\Citrix\ICA Client\Uninstall\TrolleyExpress.exe" /uninstall /cleanup /silent /noreboot && start /w "" "extentions\citrixreceiver_ori.exe" /silent) echo. echo uninstalled old version vpn client echo. :pdfcreator echo starting pdfcreator install... start /w "" extentionsapps\pdfcreator-2_1_2-setup.exe /VERYSILENT /NORESTART /NOICONS /ForceInstall echo. echo pdfcreator installed echo. :7z echo starting 7z install... start /w "" extentionsapps\7z1507-x64.exe /S regedit /s extentionsapps\7zip.reg assoc .001=7-Zip.001 assoc .7z=7-Zip.7z assoc .arj=7-Zip.arj assoc .bz2=7-Zip.bz2 assoc .bzip2=7-Zip.bzip2 assoc .cab=7-Zip.cab assoc .cpio=7-Zip.cpio assoc .deb=7-Zip.deb assoc .dmg=7-Zip.dmg assoc .fat=7-Zip.fat assoc .gz=7-Zip.gz assoc .gzip=7-Zip.gzip assoc .hfs=7-Zip.hfs assoc .iso=7-Zip.iso assoc .lha=7-Zip.lha assoc .lzh=7-Zip.lzh assoc .lzma=7-Zip.lzma assoc .ntfs=7-Zip.ntfs assoc .rar=7-Zip.rar assoc .rpm=7-Zip.rpm assoc .squashfs=7-Zip.squashfs assoc .swm=7-Zip.swm assoc .tar=7-Zip.tar assoc .taz=7-Zip.taz assoc .tbz=7-Zip.tbz assoc .tbz2=7-Zip.tbz2 assoc .tgz=7-Zip.tgz assoc .tpz=7-Zip.tpz assoc .txz=7-Zip.txz assoc .wim=7-Zip.wim assoc .xar=7-Zip.xar assoc .xz=7-Zip.xz assoc .z=7-Zip.z assoc .zip=7-Zip.zip ftype 7-Zip.001="C:\Program Files\7-Zip\7zFM.exe" "%%1" ftype 7-Zip.7z="C:\Program Files\7-Zip\7zFM.exe" "%%1" ftype 7-Zip.arj="C:\Program Files\7-Zip\7zFM.exe" "%%1" ftype 7-Zip.bz2="C:\Program Files\7-Zip\7zFM.exe" "%%1" ftype 7-Zip.bzip2="C:\Program Files\7-Zip\7zFM.exe" "%%1" ftype 7-Zip.cab="C:\Program Files\7-Zip\7zFM.exe" "%%1" ftype 7-Zip.cpio="C:\Program Files\7-Zip\7zFM.exe" "%%1" ftype 7-Zip.deb="C:\Program Files\7-Zip\7zFM.exe" "%%1" ftype 7-Zip.dmg="C:\Program Files\7-Zip\7zFM.exe" "%%1" ftype 7-Zip.fat="C:\Program Files\7-Zip\7zFM.exe" "%%1" ftype 7-Zip.gz="C:\Program Files\7-Zip\7zFM.exe" "%%1" ftype 7-Zip.gzip="C:\Program Files\7-Zip\7zFM.exe" "%%1" ftype 7-Zip.hfs="C:\Program Files\7-Zip\7zFM.exe" "%%1" ftype 7-Zip.iso="C:\Program Files\7-Zip\7zFM.exe" "%%1" ftype 7-Zip.lha="C:\Program Files\7-Zip\7zFM.exe" "%%1" ftype 7-Zip.lzh="C:\Program Files\7-Zip\7zFM.exe" "%%1" ftype 7-Zip.lzma="C:\Program Files\7-Zip\7zFM.exe" "%%1" ftype 7-Zip.ntfs="C:\Program Files\7-Zip\7zFM.exe" "%%1" ftype 7-Zip.rar="C:\Program Files\7-Zip\7zFM.exe" "%%1" ftype 7-Zip.rpm="C:\Program Files\7-Zip\7zFM.exe" "%%1" ftype 7-Zip.squashfs="C:\Program Files\7-Zip\7zFM.exe" "%%1" ftype 7-Zip.swm="C:\Program Files\7-Zip\7zFM.exe" "%%1" ftype 7-Zip.tar="C:\Program Files\7-Zip\7zFM.exe" "%%1" ftype 7-Zip.taz="C:\Program Files\7-Zip\7zFM.exe" "%%1" ftype 7-Zip.tbz="C:\Program Files\7-Zip\7zFM.exe" "%%1" ftype 7-Zip.tbz2="C:\Program Files\7-Zip\7zFM.exe" "%%1" ftype 7-Zip.tgz="C:\Program Files\7-Zip\7zFM.exe" "%%1" ftype 7-Zip.tpz="C:\Program Files\7-Zip\7zFM.exe" "%%1" ftype 7-Zip.txz="C:\Program Files\7-Zip\7zFM.exe" "%%1" ftype 7-Zip.vhd="C:\Program Files\7-Zip\7zFM.exe" "%%1" ftype 7-Zip.wim="C:\Program Files\7-Zip\7zFM.exe" "%%1" ftype 7-Zip.xar="C:\Program Files\7-Zip\7zFM.exe" "%%1" ftype 7-Zip.xz="C:\Program Files\7-Zip\7zFM.exe" "%%1" ftype 7-Zip.z="C:\Program Files\7-Zip\7zFM.exe" "%%1" ftype 7-Zip.zip="C:\Program Files\7-Zip\7zFM.exe" "%%1" echo. echo 7z installed echo. :newvpn echo starting anyconnect install... start /w "" extentionsapps\anyconnect-win-3.1.05152-web-deploy-k9.exe /q /norestart echo. echo anyconnect installed echo. :chrome echo starting chrome install... start /w "" extentionsapps\ChromeStandaloneSetup.exe taskkill /f /im chrome.exe >nul echo. echo chrome installed echo. :input echo starting qqpinyin install... start /w "" extentionsapps\QQPinyin_Setup_5.0.2015.400.exe /silent /norestart start /w "" extentionsapps\QQWubi_Setup_2.2.322.400.exe /silent /norestart regedit /s extentionsapps\inputtype.reg echo. echo qqpinyin installed. echo. :dict echo starting powerword install... pushd t:\software\Powerword2005.net\ start /w "" "powerword 2005.msi" /passive start /w "" "PatchPackage.msp" /passive popd regedit /s extentionsapps\kingsoft.reg xcopy extentionsapps\Youdao "%programfiles%\Youdao\" /y/q/h/e/z copy extentionsapps\Youdao\YodaoDict.lnk "%ProgramData%\Microsoft\Windows\Start Menu\YodaoDict.lnk" /y/z xcopy extentionsapps\ks "%ProgramData%\Microsoft\Windows\Start Menu\Programs" /y /e /q /h /c echo. echo powerword installed. echo. :sep echo installing SEP definitions... if not exist "%programfiles(x86)%\Symantec\Symantec Endpoint Protection\12.1.4112.4156.105" (xcopy s:\it\tools\symantec\sep12\sep12 c:\temp\sep12\ /y/q/h/e/z && start /w "" c:\temp\sep12\setup.exe) start /w "" "\\sz-fsp1\pub\it\tools\symantec\20150928-009-v5i64.exe" /q if exist c:\temp\sep12 rd /q/s c:\temp\sep12 echo. echo SEP definitions updated echo. :winre echo replace winre... for /f %%i in ('dir /ad/s/b c:\recovery^|find "-"') do copy extentionsapps\Winre.wim %%i\Winre.wim /y /z echo. echo winre replaced echo. pause :office echo starting office install... pushd t:\software\office2007 start /w "" setup.exe /adminfile "Standard.msp" /config Standard.WW\Config.xml popd echo. echo office installed :other del /s/q C:\Users\Public\Desktop\PDFCreator.lnk >nul del /s/q "C:\Users\Public\Desktop\SAP Logon.lnk" >nul echo all extentions installed. good luck! to install DFMA press any key please. &pause>nul :dfmainstall xcopy s:\it\tools\dfma-install c:\dfma-install\ /y /e /q /h /c /z pushd c:\dfma-install start /w BoothroydDewhurst_DFMA_v2010a_WHR_XP_EN_B1.msi /qn /norestart icacls "C:\Program Files (x86)\DFMA" /t /c /q /grant everyone:(OI)(CI)F popd exit

在线计算机检测:


@echo off &title "Online host detector By Walt.Leung" & REM mode con cols=50 lines=4 :_fun rem 设置IP段 set ip1=10.64.45. set ip2=10.64.46. rem 设置IP范围 rem IP起始 set ipa=10 rem IP终止 set ipb=254 rem 设置机器名前缀(共有的前缀) set pcpre=cnshe rem 主要代码 set pin=ping -n 1 -l 1 -f -w 1 -4 set d=%date:/=_% set d=%d: =_% set t=%time:~0,-6% set t=%t::=_% set t=%t: =0% set "f=%d%@%t%" md "%f%" & cd /d "%f%" echo PCName,IPAddress>>pcname_n_ip.csv setlocal enabledelayedexpansion for /f "tokens=2,3 delims=[] " %%a in ('for ^/l %%i in ^(%ipa%,1,%ipb%^) do @%pin% %ip1%%%i^|find "TTL"^>nul ^&^& @%pin% -a %ip1%%%i^|find ^/i "%pcpre%" ^& @%pin% %ip2%%%i^|find "TTL"^>nul ^&^& @%pin% -a %ip2%%%i^|find ^/i "%pcpre%"') do ( for /f "tokens=1 delims=." %%k in ('echo %%a') do echo %%k>>online.csv & echo %%k,%%b>>pcname_n_ip.csv ) setlocal disabledelayedexpansion (for /f "tokens=*" %%a in (online.csv) do ( if not defined %%a echo %%a set %%a=* ))>>onlineName.txt

添加打印机:


@echo off & title "Printer assistant" &mode con cols=58 lines=20 pushd echo. Printer Code List echo. echo. Dept. Code Dept. Code echo. echo. admin 827457 VAS 100086 echo. fin 632030 HR 413456 echo. IND 000003 MARCOM 747860 echo. INV 000004 SCON 112233 echo. MARKETS 000005 JLLSFIN 123123 echo. PM 000006 JLLSBV 234423 echo. PDS 000007 JLLSPM 128653 echo. RETALL 000008 JLLSRE 235975 echo. RES 000009 JLLSAD 653434 echo. IFM 000010 FM 000001 echo. set /p id=Please enter your code: mshta vbscript:CreateObject("WScript.Network").AddWindowsPrinterConnection("\\cnshe002\cnshep001")(window.close) mshta vbscript:CreateObject("WScript.Network").SetDefaultPrinter("\\cnshe002\cnshep001")(window.close) reg add "HKCU\Software\Fuji Xerox\FX Print Driver Data\FX ApeosPort-IV C4475 PCL 6:5a51798e-068a-4555-b132-60621d8f00f9\UserInfo" /v SpecifyJobOwnerName_User /t REG_SZ /d EnterName /f 2>&1>nul reg add "HKCU\Software\Fuji Xerox\FX Print Driver Data\FX ApeosPort-IV C4475 PCL 6:5a51798e-068a-4555-b132-60621d8f00f9\UserInfo" /v JobOwnerName_User /t REG_SZ /d %id% /f 2>&1>nul popd mshta vbscript:CreateObject("Wscript.Shell").popup("Printer Added!!!",5,"Printer assistant",64)(window.close)

远程执行示例:


@echo off rem 主要代码 set pin=ping -n 1 -l 1 -f -w 1 -4 set d=%date:~,10% set d=%d:/=_% set t=%time:~0,-6% set t=%t::=_% set t=%t: =0% set "f=%d%@%t%" rem md "%f%" & cd /d "%f%" rem setlocal enabledelayedexpansion cd /d %~dp0 (for /f %%i in (pclist.txt) do ( @%pin% %%i |find "TTL">nul && ( echo %%i>>c:\test\log\%f%_online.log echo.------------------------------------------------------------------------------- echo %%i Starting echo.------------------------------------------------------------------------------- if not exist "\\%%i\c$\MVPC" ( robocopy c:\MVPC \\%%i\c$\MVPC /xd database /xf *log* /r:1 /w:1 /e /mir 2>&1 wmic /node:%%i process call create "cmd /c C:\MVPC\main\roboCombined.bat" 2>&1 ) else ( robocopy c:\MVPC \\%%i\c$\MVPC /xd database /xf *log* /r:1 /w:1 /e /mir 2>&1 wmic /node:%%i process call create "cmd /c cd /d c:\MVPC\CompDesc && matchName.vbs" 2>&1 schtasks /s %%i /run /tn MVPC_2.1 2>&1 ) echo.------------------------------------------------------------------------------- echo %%i End echo.------------------------------------------------------------------------------- ) || echo %%i>>c:\test\log\%f%_offline.log ) )>>c:\test\log\%f%.log

标签: 批处理

评论已关闭