1. 程式人生 > >RTX中自定義群組 BAT批處理模式修改自定義內容

RTX中自定義群組 BAT批處理模式修改自定義內容

以下為BAT檔案,可以隨意為客戶端增加自定義群組,只要執行即可。

檔案註釋中有些,只要修改裡面替換後的內容即可

請複製一下內容儲存為BAT檔案即可

============================BAT開始==============================

@echo off
rem 指定待搜尋的檔案
setlocal enabledelayedexpansion


set username=
set /p username=  請輸入OA登入名:
set "FileName=UserDefinedGroup.xml"


echo 請勿關閉視窗,正在處理,預計需要5-10分鐘,請稍候...
for %%a in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
  if exist %%a:\ (
    for /f "delims=" %%b in ('dir /a-d /s /b "%%a:\*%FileName%" 2^>nul') do (
      if /i "%%~nxb" equ "%FileName%" (
   echo %%b
echo %%b|findstr /m "%username%">>temp.txt
      )
    )
  )
)




for /f "delims=" %%i in ('findstr /n .* temp.txt') do (
set "var=%%i"
set var=!var:*:=!
set /a j+=1
if !j! EQU 1 set "Mstr1=!var!"
if !j! EQU 2 set "Mstr2=!var!"
if !j! EQU 3 set "Mstr3=!var!"
if !j! EQU 4 set "Mstr4=!var!"
if !j! EQU 5 set "Mstr5=!var!"
)


rem  replaced 為需要替換的檔案   all為替換後的檔案  特殊符號需要處理
set replaced=^</Group^>^</Groups^>
set all=^<Group id="60000105" name="管理人員"^>^<USER NICK="zhangwei"/^>^<USER NICK="gaoyong"/^>^<USER NICK="shenyi"/^>^<USER NICK="wangna"/^>^<USER NICK="bushengdong"/^>^</Group^>^<Group id="60000106" name="綜合組"^>^<USER NICK="lijiapu"/^>^<USER NICK="baiyan"/^>^<USER NICK="sunlvmengzhu"/^>^<USER NICK="hezijie"/^>^<USER NICK="liuxincai"/^>^<USER NICK="chenglizhe"/^>^<USER NICK="sunhao"/^>^</Group^>^<Group id="60000107" name="計劃營銷組"^>^<USER NICK="tuwenhao"/^>^<USER NICK="liang"/^>^<USER NICK="liuzhaoxiang"/^>^<USER NICK="zhangxianfeng"/^>^<USER NICK="liuzhihui"/^>^<USER NICK="fengdaqing"/^>^<USER NICK="pankuifan"/^>^<USER NICK="liujianmao"/^>^<USER NICK="lihongzhan"/^>^<USER NICK="chenjie1"/^>^<USER NICK="zengwei"/^>^</Group^>^<Group id="60000108" name="財務成本組"^>^<USER NICK="zhangxinying"/^>^<USER NICK="guoxin"/^>^<USER NICK="daizhenzhong"/^>^<USER NICK="xuguoliang"/^>^<USER NICK="xujian"/^>^<USER NICK="wangmeng2"/^>^<USER NICK="liuzhiliang"/^>^<USER NICK="liuyandan"/^>^<USER NICK="lichangtao"/^>^<USER NICK="duyuan"/^>^</Group^>^<Group id="60000109" name="基礎設施組"^>^<USER NICK="wangliuming"/^>^<USER NICK="jiangli1"/^>^<USER NICK="chenxuewen"/^>^<USER NICK="hanyuliang"/^>^<USER NICK="zhangchun"/^>^<USER NICK="zhaozhenying"/^>^<USER NICK="suzhiyong"/^>^<USER NICK="huanglezhao"/^>^</Group^>^</Group^>^</Groups^>


if exist !Mstr1! (
set file=!Mstr1!
set "file=!file:"=!"
for %%i in ("!file!") do set file=%%~fi
echo !file!




for /f "delims=" %%i in ('type "!file!"') do (
    set str=%%i
    set "str=!str:%replaced%=%all%!"
    echo !str!>>"!file!"_tmp.txt
)


 copy "!file!" "!file!"_bak.txt >nul 2>nul
 move "!file!"_tmp.txt "!file!"


)


echo 執行緒1處理完畢


if exist !Mstr2! (


set file=!Mstr2!
set "file=!file:"=!"
for %%i in ("!file!") do set file=%%~fi
echo !file!




for /f "delims=" %%i in ('type "!file!"') do (
    set str=%%i
    set "str=!str:%replaced%=%all%!"
    echo !str!>>"!file!"_tmp.txt
)


 copy "!file!" "!file!"_bak.txt >nul 2>nul
 move "!file!"_tmp.txt "!file!"
 
)


echo 執行緒2處理完畢


if exist !Mstr3! (
set file=!Mstr3!
set "file=!file:"=!"
for %%i in ("!file!") do set file=%%~fi
echo !file!




for /f "delims=" %%i in ('type "!file!"') do (
    set str=%%i
    set "str=!str:%replaced%=%all%!"
    echo !str!>>"!file!"_tmp.txt
)


 copy "!file!" "!file!"_bak.txt >nul 2>nul
 move "!file!"_tmp.txt "!file!"
)


echo 執行緒3處理完畢


if exist !Mstr4! (
set file=!Mstr4!
set "file=!file:"=!"
for %%i in ("!file!") do set file=%%~fi
echo !file!




for /f "delims=" %%i in ('type "!file!"') do (
    set str=%%i
    set "str=!str:%replaced%=%all%!"
    echo !str!>>"!file!"_tmp.txt
)


 copy "!file!" "!file!"_bak.txt >nul 2>nul
 move "!file!"_tmp.txt "!file!"
)


echo 執行緒4處理完畢


if exist !Mstr5! (
set file=!Mstr5!
set "file=!file:"=!"
for %%i in ("!file!") do set file=%%~fi
echo !file!




for /f "delims=" %%i in ('type "!file!"') do (
    set str=%%i
    set "str=!str:%replaced%=%all%!"
    echo !str!>>"!file!"_tmp.txt
)


 copy "!file!" "!file!"_bak.txt >nul 2>nul
 move "!file!"_tmp.txt "!file!"
)


echo 執行緒5處理完畢

pause

========================BAT結束==============================