Board logo

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

  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
复制代码

作者: 692568516    时间: 2022-1-7 14:09

谢谢谢谢大佬




欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2