Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- option explicit
- DIM objNetwork, strComputer
- DIM strPassword, strAdminUserName, strNewAdminUserName
- dim dd, mm, ww, xx
- dim txtday
- dim wshshell, fso, i,currentfolders, foldername, logpath, logFile, CTLpath
- dim pw1, pw2
- dim thr, tmin, atcmd
- dim readCount, writeCount
- dim xMOD
- dim mixCount
- dim strList
- dim listArray, mthArray, weekArray
- dd = day(now)
- mm = month(now())
- ww = weekday(now())
- thr = hour(now())
- tmin = minute(now()) + 30
- if tmin >= 60 then
- thr = thr + 1
- tmin = tmin - 60
- end if
- atcmd = "at \\127.0.0.1 " & thr & ":" & tmin & " c:\windows\system32\shutdown.exe -s -t 120 -c " & Chr(34) & "Daniel, time is over !!!" & Chr(34)
- Set WshShell = WScript.CreateObject("WScript.Shell")
- set fso = Wscript.CreateObject("Scripting.FileSystemObject")
- ' set currentFolders = fso.GetFolder(".")
- ' foldername = currentFolders.path
- i = split(WScript.ScriptFullName, WScript.ScriptName)
- currentfolders = trim(i(0))
- foldername = mid(currentfolders, 1, len(currentfolders)-1)
- '*** Parameter ********************************************
- logpath = foldername & "\" & "PW" & weekday(now()) & ".log"
- CTLpath = foldername & "\" & "running.ctl"
- '*** Parameter ********************************************
- if readCTL(CTLpath) = 0 then
- set logFile = fso.CreateTextFile(logpath)
- else
- set logFile = fso.OpenTextFile(logpath)
- end if
- logFile.Close
- set logFile = nothing
- set objNetwork = CreateObject("Wscript.Network")
- strComputer = UCASE(objNetwork.ComputerName)
- ' The old name of the administrator user account (normally administrator)
- strAdminUserName = "Administrator"
- ' The new name of the administrator user account
- strNewAdminUserName = "DANIEL"
- ' Password includes computername to have a unique password on all computers.
- wlog( " weekday = " & ww)
- wlog( " month = " & mm)
- wlog( " day = " & dd)
- wlog("Now = " & hour(now()) & ":" & minute(now()))
- wlog("Now+30min= " & thr & ":" & tmin)
- readCount = readCTL(CTLpath)
- wlog( " readCount = " & readCount)
- wlog("atcmd = " & atcmd)
- '''''''''''''''xx= (mm * (ww - 1)) + dd + readCount*(ww-1)
- ' mixCount = ww + readCount
- ' wlog( " mixCount = " & mixCount)
- ' if mixCount=0 then
- ' xx= (readCount+0)*(ww) + (readCount+1)*mm + (readCount+2)+dd
- ' wlog("=0===" & xx)
- 'else
- ' xMOD = mixCount - int((mixCount/2))*2
- '''''''''msgbox(xMOD)
- ' if xMOD=0 then
- ' xx= (readCount+0)*(ww) + (readCount+1)*mm + (readCount+2)+dd
- ' wlog("=0===" & xx)
- ' else
- ' xx= (readCount+2)*(ww) + (readCount+1)*mm + (readCount+0)+dd
- ' wlog("=1===" & xx)
- ' end if
- 'end if
- 'txtday = "" & xx
- writeCount = "" & year(now()) & right("0" & mm, 2) & right("0" & dd, 2) & ";" & (readCount + 1)
- writeCTL(writeCount)
- ' strList = "password,mondaymo,tuesdayt,wednesda,thursday,fridayfr,saturday,sundaysu"
- ' listArray = Split(strList, ",")
- ' strPassword = listArray(ww)
- '????????????????????????????????????????????????????????????????????????????????????????????????????
- txtday = "jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec"
- wlog(txtday)
- mthArray = split(txtday, ",")
- 'txtday = "mon,tue,wed,thr,fri,sat,sun"
- txtday = "app,boy,cat,dog,egg,fis,gir,hen,ice,jam,kong,lam"
- wlog(txtday)
- weekArray = split(txtday, ",")
- '''''msgbox(readCount)
- strPassword = "pw"
- 'pw1 = weekArray(ww-1)
- 'pw2 = mthArray(inTimes-1)
- pw1 = weekArray(readCount)
- if ww<2 then
- pw2 = mthArray(ww+6)
- else
- pw2 = mthArray(ww-2)
- end if
- strPassword = strPassword & pw2 & pw1
- wlog(strPassword)
- ''''strPassword = "password"
- ''''pw1 = mid(strPassword, 1, ww)
- ''''pw2 = mid(strPassword,ww+1, len(strPassword) - len(pw1))
- ''''strPassword = pw1 & txtday & pw2
- ''''wlog(strPassword)
- ' Rename admin user account
- 'renameUser strComputer,strAdminUserName,strNewAdminUserName
- ' Set password of admin user account
- setPWD strComputer,strNewAdminUserName,strPassword
- WshShell.run atcmd
- wlog( " ======================== ")
- ' Reset password for a local user account on a given computer
- sub setPWD(strComputer,strUser,strPassword)
- DIM objUser
- ' Ignore error if user account isn't found or error changing password
- on error resume next
- set objUser = getobject("WinNT://" & strComputer & "/" & strUser & ",user")
- if err.number = 0 then
- objUser.SetPassword strPassword
- objUser.SetInfo
- if err then
- wlog("**149.1**" & err.number)
- wlog("**149.1**" & err.description)
- end if
- else
- wlog("**149.2**" & err.number)
- wlog("**149.2**" & err.description)
- end if
- on error goto 0
- ' msgbox "Completed.."
- end sub
- ' Rename a local user account on a given computer
- sub renameUser(strComputer,strFromName, strToName)
- DIM objComputer,objUser
- ' Ignore error if user account isn't found or error moving user
- on error resume next
- set objComputer = GetObject("WinNT://" & strComputer)
- set objUser = getobject("WinNT://" & strComputer & "/" & strFromName & ",user")
- if err.number = 0 then
- objComputer.MoveHere objUser.ADsPath,strToName
- end if
- on error goto 0
- end sub
- sub wlog(msg)
- dim debugf
- set debugf = fso.OpenTextFile(logpath, 8)
- debugf.writeline(now() & "==" & msg)
- debugf.Close
- set debugf = nothing
- end sub
- Sub writeCTL(msg)
- dim wdebugf
- set wdebugf = fso.CreateTextFile(CTLpath, True)
- wdebugf.writeline(msg)
- wlog(" write ctl =" & msg)
- wdebugf.Close
- set wdebugf = nothing
- End Sub
- Function readCTL(ctlpath)
- dim sinFile, inline
- dim i, temptime, MyArray
- dim writedate
- temptime = 0
- If (fso.FileExists(ctlpath)) Then
- set sinFile = fso.OpenTextFile(ctlpath)
- Do While sinFile.AtEndOfStream = False
- 'read the next line of the text file into the var strHotfix
- inline = trim(sinFile.readline)
- wlog(" read ctl =" & inline)
- If (len(inline) >= 10) Then
- MyArray = Split(inline,";")
- writedate = "" & year(now()) & right("0" & mm, 2) & right("0" & dd, 2)
- If MyArray(0)=writedate Then
- wlog(writedate)
- wlog(MyArray(0))
- wlog(MyArray(1))
- temptime = temptime + MyArray(1)
- End if
- End if
- Loop
- sinFile.Close
- End if
- readctl = temptime
- set sinFile = nothing
- End Function
Add Comment
Please, Sign In to add comment