
求助隨機數批處理for/f+變量的問題閃退
nclick="copycode($('code0'));">復制代碼
- @echo off
- setlocal enabledelayedexpansion
- set a=012345789ABCDEF
- set /a b=%random%%%14+1
- set /a c=%random%%%14+1
- set /a d=%random%%%14+1
- set /a e=%random%%%14+1
- set /a f=%random%%%14+1
- set /a g=%random%%%14+1
- set /a h=%random%%%14+1
- set /a i=%random%%%14+1
- set /a j=%random%%%14+1
- set /a k=%random%%%14+1
- set /a l=%random%%%14+1
- set /a m=%random%%%14+1
- set name32=12345678901234567890!a:~%b%,1!!a:~%c%,1!!a:~%d%,1!!a:~%e%,1!!a:~%f%,1!!a:~%g%,1!!a:~%h%,1!!a:~%i%,1!!a:~%j%,1!!a:~%k%,1!!a:~%l%,1!!a:~%m%,1!
- set /a aa=%random%%%10+1
- set /a bb=%random%%%10+1
- set /a cc=%random%%%10+1
- set /a dd=%random%%%10+1
- set proccessId=%aa%%bb%%cc%%dd%
- set /a n1=%random%%%2+1
- set /a n9=%random%%%10+1
- set /a n5=%random%%%5+1
- set createDate=%today%%n1%%n9%%n5%%n9%%n5%%n9%
- echo.隨機32位!name32!
- echo.隨機日期!createDate!
- echo.隨機4位數!proccessId!
- set today=%date:~5,2%%date:~8,2%
- set muji=E:ProgramDataWindroyeWindroye_4E513D9BC016A2AADA0CF6F6426390EB
- pause
- for /l %%i in (1 1 2) do (
- xcopy /a /s /y !muji!*.* E:Windroye_!name32!
- (echo, <host>
- echo,<name>!today!%%i</name>
- echo,<vdiPath>E:ProgramData</vdiPath>
- echo,<vbName>Windroye_!name32!</vbName>
- echo,<createDate>!createDate!</createDate>
- echo,<defStart>0</defStart>
- echo,<proccessId>!proccessId!</proccessId>
- echo, </host> )^>>MutiConfig.xml
- )
- echo <VitualMachine>^>>MutiConfig.xml
- pause

