天天看點

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循環、變量嵌套、指令嵌套

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

本文轉自 freeterman 51CTO部落格,原文連結:http://blog.51cto.com/myunix/1345521,如需轉載請自行聯系原作者

繼續閱讀