[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[系统相关] [已解决]批处理如何批量赋予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

  1. @echo off & setlocal enabledelayedexpansion
  2. set targe=''
  3. for /f   %%i in (user.txt)  do (
  4. set target=%%i
  5. call :getpw
  6. net user !target! !pw! /add
  7. net user !target! /FULLNAME:!target!  /COMMENT:"由bat创建"
  8. net localgroup users !target! admintemp /delete
  9. C:\Windows\System32\inetsrv\appcmd.exe add apppool /apppool.name:!target!
  10. 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!
  11. )
  12. pause
  13. exit /b
  14. :getpw
  15. set pw=
  16. set ws=14
  17. set str=0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
  18. for /l %%a in (1,1,%ws%) do (
  19.     set /a num=!random!%%62
  20.     call set zf=%%str:~!num!,1%%
  21.     set pw=!pw!!zf!
  22. )
  23. exit /b
复制代码
微信:flashercs
QQ:49908356

TOP

谢谢谢谢大佬

TOP

返回列表