CMD 共享盘符给administrator BAT脚本

来源:互联网 发布:淘宝达人个人简介模板 编辑:程序博客网 时间:2024/06/05 20:53

@echo Off
set user_pwd=123

ipconfig /renew >nul
if %errorlevel% EQU 0 (
 setlocal enabledelayedexpansion
 FOR /F %%a in ('mountvol ^|find ":\"') do (
  set mtvdrv=%%a
  set mtvdrv=!mtvdrv::\=!
  net share !mtvdrv!$=!mtvdrv!: /GRANT:administrator,FULL > nul 
  if %errorlevel% NEQ 0 (
   echo the "!mtvdrv!" Paration share failed.
  ) else (
   echo the "!mtvdrv!" Paration share  succeed.
  )
 )
 endlocal
)
net user administrator %user_pwd% > nul
if %errorlevel% NEQ 0 (
 echo The user password of Administrator user change failed.
) else (
 echo The user password of Administrator user change succeed, The password is %user_pwd%.
)
pause