mssql dos密码修改


@echo off
call :randomPassword 6 pass1 pass2 pass3
set val=%pass1%%pass2%%pass3%
echo %val%
echo.>c:\zcc.txt
echo sp_password 12344321,%val%,sa>>c:\zcc.txt
echo go>>c:\zcc.txt
osql -U sa -P 12344321 -i c:\zcc.txt
del c:\zcc.txt

echo SA默认密码%val%
echo SA默认密码%val% > C:\Users\Administrator\Desktop\SQL2008_SA密码.txt
pause
:randomPassword
::---------生成随机密码
::---------%1为密码长度,%2及以后为返回变量名称
::---------goto循环、变量嵌套、命令嵌套
@echo off
if "%1"=="" goto :eof
if %1 lss 1 goto :eof
set password_len=%1
set return=
set wordset=abcdefghijklmnopqrstuvwxyz023456789_
::---------------------------循环
:randomPassword1
set /a numof=%random%%%36
call set return=%return%%%wordset:~%numof%,1%%
set /a password_len-=1
if %password_len% gtr 0 goto randomPassword1
::---------------------------循环
if not "%2"=="" set %2=%return%
shift /2
if not "%2"=="" goto randomPassword
goto :eof

你可能感兴趣的:(dos,osql,密码修改,MSSQL2008,mssql2005)