Guest User

Untitled

a guest
Jan 19th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.42 KB | None | 0 0
  1. option explicit
  2. DIM objNetwork, strComputer
  3. DIM strPassword, strAdminUserName, strNewAdminUserName
  4. dim dd, mm, ww, xx
  5. dim txtday
  6. dim wshshell, fso, i,currentfolders, foldername, logpath, logFile, CTLpath
  7. dim pw1, pw2
  8. dim thr, tmin, atcmd
  9. dim readCount, writeCount
  10. dim xMOD
  11. dim mixCount
  12. dim strList
  13. dim listArray, mthArray, weekArray
  14.  
  15. dd = day(now)
  16. mm = month(now())
  17. ww = weekday(now())
  18. thr = hour(now())
  19. tmin = minute(now()) + 30
  20. if tmin >= 60 then
  21. thr = thr + 1
  22. tmin = tmin - 60
  23. end if
  24. 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)
  25.  
  26. Set WshShell = WScript.CreateObject("WScript.Shell")
  27. set fso = Wscript.CreateObject("Scripting.FileSystemObject")
  28. ' set currentFolders = fso.GetFolder(".")
  29. ' foldername = currentFolders.path
  30.  
  31. i = split(WScript.ScriptFullName, WScript.ScriptName)
  32. currentfolders = trim(i(0))
  33. foldername = mid(currentfolders, 1, len(currentfolders)-1)
  34.  
  35. '*** Parameter ********************************************
  36. logpath = foldername & "\" & "PW" & weekday(now()) & ".log"
  37. CTLpath = foldername & "\" & "running.ctl"
  38. '*** Parameter ********************************************
  39.  
  40. if readCTL(CTLpath) = 0 then
  41. set logFile = fso.CreateTextFile(logpath)
  42. else
  43. set logFile = fso.OpenTextFile(logpath)
  44. end if
  45. logFile.Close
  46. set logFile = nothing
  47.  
  48. set objNetwork = CreateObject("Wscript.Network")
  49. strComputer = UCASE(objNetwork.ComputerName)
  50.  
  51. ' The old name of the administrator user account (normally administrator)
  52. strAdminUserName = "Administrator"
  53. ' The new name of the administrator user account
  54. strNewAdminUserName = "DANIEL"
  55. ' Password includes computername to have a unique password on all computers.
  56.  
  57. wlog( " weekday = " & ww)
  58. wlog( " month = " & mm)
  59. wlog( " day = " & dd)
  60. wlog("Now = " & hour(now()) & ":" & minute(now()))
  61. wlog("Now+30min= " & thr & ":" & tmin)
  62. readCount = readCTL(CTLpath)
  63. wlog( " readCount = " & readCount)
  64. wlog("atcmd = " & atcmd)
  65. '''''''''''''''xx= (mm * (ww - 1)) + dd + readCount*(ww-1)
  66. ' mixCount = ww + readCount
  67. ' wlog( " mixCount = " & mixCount)
  68. ' if mixCount=0 then
  69. ' xx= (readCount+0)*(ww) + (readCount+1)*mm + (readCount+2)+dd
  70. ' wlog("=0===" & xx)
  71. 'else
  72. ' xMOD = mixCount - int((mixCount/2))*2
  73. '''''''''msgbox(xMOD)
  74. ' if xMOD=0 then
  75. ' xx= (readCount+0)*(ww) + (readCount+1)*mm + (readCount+2)+dd
  76. ' wlog("=0===" & xx)
  77. ' else
  78. ' xx= (readCount+2)*(ww) + (readCount+1)*mm + (readCount+0)+dd
  79. ' wlog("=1===" & xx)
  80. ' end if
  81. 'end if
  82. 'txtday = "" & xx
  83. writeCount = "" & year(now()) & right("0" & mm, 2) & right("0" & dd, 2) & ";" & (readCount + 1)
  84. writeCTL(writeCount)
  85.  
  86. ' strList = "password,mondaymo,tuesdayt,wednesda,thursday,fridayfr,saturday,sundaysu"
  87. ' listArray = Split(strList, ",")
  88. ' strPassword = listArray(ww)
  89. '????????????????????????????????????????????????????????????????????????????????????????????????????
  90.  
  91. txtday = "jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec"
  92. wlog(txtday)
  93. mthArray = split(txtday, ",")
  94. 'txtday = "mon,tue,wed,thr,fri,sat,sun"
  95. txtday = "app,boy,cat,dog,egg,fis,gir,hen,ice,jam,kong,lam"
  96. wlog(txtday)
  97. weekArray = split(txtday, ",")
  98.  
  99.  
  100. '''''msgbox(readCount)
  101.  
  102.  
  103.  
  104. strPassword = "pw"
  105. 'pw1 = weekArray(ww-1)
  106. 'pw2 = mthArray(inTimes-1)
  107. pw1 = weekArray(readCount)
  108. if ww<2 then
  109. pw2 = mthArray(ww+6)
  110. else
  111. pw2 = mthArray(ww-2)
  112. end if
  113. strPassword = strPassword & pw2 & pw1
  114. wlog(strPassword)
  115.  
  116.  
  117. ''''strPassword = "password"
  118. ''''pw1 = mid(strPassword, 1, ww)
  119. ''''pw2 = mid(strPassword,ww+1, len(strPassword) - len(pw1))
  120. ''''strPassword = pw1 & txtday & pw2
  121. ''''wlog(strPassword)
  122.  
  123.  
  124.  
  125. ' Rename admin user account
  126. 'renameUser strComputer,strAdminUserName,strNewAdminUserName
  127.  
  128. ' Set password of admin user account
  129. setPWD strComputer,strNewAdminUserName,strPassword
  130.  
  131. WshShell.run atcmd
  132. wlog( " ======================== ")
  133.  
  134.  
  135.  
  136.  
  137.  
  138. ' Reset password for a local user account on a given computer
  139. sub setPWD(strComputer,strUser,strPassword)
  140.  
  141. DIM objUser
  142. ' Ignore error if user account isn't found or error changing password
  143. on error resume next
  144. set objUser = getobject("WinNT://" & strComputer & "/" & strUser & ",user")
  145. if err.number = 0 then
  146. objUser.SetPassword strPassword
  147. objUser.SetInfo
  148. if err then
  149. wlog("**149.1**" & err.number)
  150. wlog("**149.1**" & err.description)
  151. end if
  152. else
  153. wlog("**149.2**" & err.number)
  154. wlog("**149.2**" & err.description)
  155. end if
  156. on error goto 0
  157. ' msgbox "Completed.."
  158.  
  159. end sub
  160.  
  161. ' Rename a local user account on a given computer
  162. sub renameUser(strComputer,strFromName, strToName)
  163.  
  164. DIM objComputer,objUser
  165. ' Ignore error if user account isn't found or error moving user
  166. on error resume next
  167. set objComputer = GetObject("WinNT://" & strComputer)
  168. set objUser = getobject("WinNT://" & strComputer & "/" & strFromName & ",user")
  169. if err.number = 0 then
  170. objComputer.MoveHere objUser.ADsPath,strToName
  171. end if
  172. on error goto 0
  173.  
  174. end sub
  175.  
  176. sub wlog(msg)
  177. dim debugf
  178. set debugf = fso.OpenTextFile(logpath, 8)
  179. debugf.writeline(now() & "==" & msg)
  180. debugf.Close
  181. set debugf = nothing
  182. end sub
  183.  
  184. Sub writeCTL(msg)
  185. dim wdebugf
  186. set wdebugf = fso.CreateTextFile(CTLpath, True)
  187. wdebugf.writeline(msg)
  188. wlog(" write ctl =" & msg)
  189. wdebugf.Close
  190. set wdebugf = nothing
  191. End Sub
  192.  
  193. Function readCTL(ctlpath)
  194. dim sinFile, inline
  195. dim i, temptime, MyArray
  196. dim writedate
  197.  
  198. temptime = 0
  199. If (fso.FileExists(ctlpath)) Then
  200. set sinFile = fso.OpenTextFile(ctlpath)
  201. Do While sinFile.AtEndOfStream = False
  202. 'read the next line of the text file into the var strHotfix
  203. inline = trim(sinFile.readline)
  204. wlog(" read ctl =" & inline)
  205. If (len(inline) >= 10) Then
  206. MyArray = Split(inline,";")
  207. writedate = "" & year(now()) & right("0" & mm, 2) & right("0" & dd, 2)
  208. If MyArray(0)=writedate Then
  209. wlog(writedate)
  210. wlog(MyArray(0))
  211. wlog(MyArray(1))
  212. temptime = temptime + MyArray(1)
  213. End if
  214. End if
  215. Loop
  216. sinFile.Close
  217. End if
  218. readctl = temptime
  219. set sinFile = nothing
  220. End Function
Add Comment
Please, Sign In to add comment