标题: [系统相关] [已解决]批处理如何批量赋予IIS程序池独立用户? [打印本页]
作者: 692568516 时间: 2022-1-6 16:43 标题: [已解决]批处理如何批量赋予IIS程序池独立用户?
本帖最后由 692568516 于 2022-1-7 17:58 编辑
请教下以下两个脚本如何拼成一个,需要吧生成密码的脚本放到for 循环里,随机生成密码并赋予用户和程序池
@echo off & setlocal enabledelayedexpansion
set ws=14
set str=0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
for /l %%a in (1,1,%ws%) do (
set /a num=!random!%%62
call set zf=%%str:~!num!,1%%
set pw=!pw!!zf!
)
set targe=''
for /f %%i in (user.txt) do (
set target=%%i
net user !target! !pw! /add
net user !target! /FULLNAME:!target! /COMMENT:"由bat创建"
net localgroup users !target! admintemp /delete
C:\Windows\System32\inetsrv\appcmd.exe add apppool /apppool.name:!target!
C:\Windows\System32\inetsrv\appcmd.exe set config /section:applicationPools /[name='!target!'].processModel.identityType:SpecificUser /[name='!target!'].processModel.userName:!target! /[name='!target!'].processModel.password:!pw!
)
pause
作者: flashercs 时间: 2022-1-6 23:01
- @echo off & setlocal enabledelayedexpansion
-
- set targe=''
- for /f %%i in (user.txt) do (
- set target=%%i
- call :getpw
- net user !target! !pw! /add
- net user !target! /FULLNAME:!target! /COMMENT:"由bat创建"
- net localgroup users !target! admintemp /delete
- C:\Windows\System32\inetsrv\appcmd.exe add apppool /apppool.name:!target!
- C:\Windows\System32\inetsrv\appcmd.exe set config /section:applicationPools /[name='!target!'].processModel.identityType:SpecificUser /[name='!target!'].processModel.userName:!target! /[name='!target!'].processModel.password:!pw!
- )
- pause
- exit /b
-
- :getpw
- set pw=
- set ws=14
- set str=0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
- for /l %%a in (1,1,%ws%) do (
- set /a num=!random!%%62
- call set zf=%%str:~!num!,1%%
- set pw=!pw!!zf!
- )
- exit /b
复制代码
作者: 692568516 时间: 2022-1-7 14:09
谢谢谢谢大佬
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |