Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.36 KB | None | 0 0
  1. OPTION EXPLICIT
  2.  
  3. ' ms "starting" ' ms is a message box sub with vbcr cancel
  4. '234567890'234567890'234567890'234567890'234567890'234567890'234567890'234567890 scale helps debugging error messages
  5.  
  6.  
  7. ' special folders
  8.  
  9. ' AllUsersDesktop
  10. ' AllUsersStartMenu
  11. ' AllUsersPrograms
  12. ' AllUsersStartup
  13. ' Desktop
  14. ' Favorites
  15. ' Fonts
  16. ' MyDocuments
  17. ' NetHood
  18. ' PrintHood
  19. ' Programs
  20. ' Recent
  21. ' SendTo
  22. ' StartMenu
  23. ' Startup
  24. ' Templates
  25.  
  26. dim recurseCount
  27.  
  28. DIM rc
  29. DIM lnkString
  30. DIM strFolder
  31. DIM IncludeSubFolders
  32. DIM objFSO
  33. Dim objNetwork
  34. Dim objShell
  35. Dim msg
  36. Dim HotKeyCount
  37. HotKeyCount = 0
  38. ' ************************************************************
  39. ' Setup
  40. ' ************************************************************
  41. SET objShell = CREATEOBJECT("wscript.shell")
  42.  
  43. SET objFSO = CREATEOBJECT("Scripting.FileSystemObject")
  44. Set objNetwork = CreateObject("WScript.Network")
  45. SET objFSO = CREATEOBJECT("Scripting.FileSystemObject")
  46. lnkString = ""
  47. recurseCount = 0
  48.  
  49. ' finally found the short that had the zombie hot key in
  50. ' --> C:UserspkryderAppDataRoamingMicrosoftInternet ExplorerQuick LaunchUser PinnedTaskBar
  51. ' it was also in --> C:UserspkryderAppDataRoamingMicrosoftIMJP10
  52. ' how why?
  53.  
  54.  
  55. ' C:ProgramDataMicrosoftWindows
  56. strFolder = "C:ProgramDataMicrosoftWindows" ' objShell.SpecialFolders.Item ("Templates")
  57. FindHotKeys strFolder
  58.  
  59.  
  60. ' C:ProgramDataMicrosoftWindows
  61. strFolder = "C:users" ' objShell.SpecialFolders.Item ("Templates")
  62. FindHotKeys strFolder
  63.  
  64.  
  65.  
  66.  
  67. strFolder = objShell.SpecialFolders.Item("AllUsersStartup")
  68. FindHotKeys strFolder
  69.  
  70. strFolder = objShell.SpecialFolders.Item("Programs")
  71. FindHotKeys strFolder
  72.  
  73. strFolder = objShell.SpecialFolders.Item("Desktop")
  74. FindHotKeys strFolder
  75.  
  76.  
  77. ' "AllUsersDesktop"
  78. strFolder = objShell.SpecialFolders.Item("AllUsersDesktop")
  79. FindHotKeys strFolder
  80.  
  81. ' AllUsersStartMenu
  82. strFolder = objShell.SpecialFolders.Item ("AllUsersStartMenu")
  83. FindHotKeys strFolder
  84.  
  85.  
  86. ' AllUsersPrograms
  87.  
  88. strFolder = objShell.SpecialFolders.Item ("AllUsersStartMenu")
  89. FindHotKeys strFolder
  90.  
  91. strFolder = objShell.SpecialFolders.Item ("AllUsersStartup")
  92. FindHotKeys strFolder
  93. strFolder = objShell.SpecialFolders.Item ("Desktop")
  94. FindHotKeys strFolder
  95. strFolder = objShell.SpecialFolders.Item ("Favorites")
  96. FindHotKeys strFolder
  97. strFolder = objShell.SpecialFolders.Item ("Fonts")
  98. FindHotKeys strFolder
  99. strFolder = objShell.SpecialFolders.Item ("MyDocuments")
  100. FindHotKeys strFolder
  101. strFolder = objShell.SpecialFolders.Item ("NetHood")
  102. FindHotKeys strFolder
  103. strFolder = objShell.SpecialFolders.Item ("PrintHood")
  104. FindHotKeys strFolder
  105. strFolder = objShell.SpecialFolders.Item ("Programs")
  106. FindHotKeys strFolder
  107. strFolder = objShell.SpecialFolders.Item ("Recent")
  108. FindHotKeys strFolder
  109. strFolder = objShell.SpecialFolders.Item ("SendTo")
  110. FindHotKeys strFolder
  111. strFolder = objShell.SpecialFolders.Item ("StartMenu")
  112. FindHotKeys strFolder
  113. strFolder = objShell.SpecialFolders.Item ("Startup")
  114. FindHotKeys strFolder
  115. strFolder = objShell.SpecialFolders.Item ("Templates")
  116. FindHotKeys strFolder
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130. if lnkString = "" then
  131. ms "no hotkeys wer found"
  132. else
  133. if HotKeyCount = 1 then
  134. ms "done " &vbcr & HotKeyCount & " hotKey was found " & vbcr & lnkString
  135. else
  136. ms "done " &vbcr & HotKeyCount & " hotKeys were found " & vbcr & lnkString
  137. end if
  138. end if
  139.  
  140.  
  141.  
  142.  
  143. SUB FindHotKeys(BYVAL strDirectory)
  144. DIM objFolder
  145. DIM objSubFolder
  146. DIM objFile
  147. DIM strExt
  148. DIM errSav
  149. Dim n1
  150. Dim ws1
  151. Dim errSav2
  152. dim errSav3
  153. dim bIsAshortcut
  154. Dim n2
  155. Dim n3
  156. Dim intMsgSave
  157.  
  158.  
  159.  
  160. n3 = 9999
  161. n2 = 9999
  162. n1 = 9999
  163. ws1 = n1
  164. dim FileCount
  165. dim SubFolderCount
  166.  
  167. on error goto 0
  168.  
  169. errSav = 0
  170. errSav2 = 0
  171. errSav3 = 0
  172. bIsAshortcut = false
  173.  
  174.  
  175.  
  176. msg = "strDirectory" & vbcr & vbcr & strDirectory
  177. ' ms msg & vbcr & "076"
  178.  
  179. '234567890'234567890'234567890'234567890'234567890'234567890'234567890'234567890 scale helps debugging error messages
  180. on error goto 0
  181. on error resume next
  182.  
  183. SET objFolder = objFSO.GetFolder(strDirectory)
  184. errSav = err.number
  185.  
  186. FileCount = objFolder.files.count
  187. errSav2 = err.number
  188. SubFolderCount = objFolder.SubFolders.count
  189. on error goto 0
  190.  
  191.  
  192. msg = msg & vbcr & "errSav2:" & errSav2 & vbcr & "errSav:" & errSav
  193. msg = msg & vbcr & "FileCount:" & FileCount
  194. msg = msg & vbcr & "SubFolderCount:" & SubFolderCount
  195.  
  196. ' ms msg & vbcr & "092"
  197.  
  198.  
  199. If errSav = 0 then ' we have subfolders
  200.  
  201. on error resume next
  202. FOR EACH objSubFolder in objFolder.SubFolders
  203. errSav2 = err.number
  204. on error goto 0
  205. If errSav2 = 0 then
  206. ' ms "102"
  207. recurseCount = recurseCount + 1
  208. FindHotKeys objSubFolder.Path ' recurse through this new sub folder
  209. recurseCount = recurseCount - 1
  210. ' ms "110"
  211. end if
  212. on error resume next
  213. NEXT
  214. on error goto 0
  215.  
  216. ' ms "115" & vbcr & "in files" & vbcr& vbcr & strDirectory
  217.  
  218. n2 = 0
  219. on error resume next ' had some trouble with file not found? so ignore that
  220. FOR EACH objFile in objFolder.Files
  221. errSav = err.number
  222. n2 = n2 + 1
  223. dim sObjFileName
  224. dim iLength
  225. sObjFileName = objFile.name
  226. errSav3 = err.number
  227. on error goto 0
  228. iLength = len(sObjFileName)
  229.  
  230. bIsAshortcut = false
  231. if (right(sObjFileName,4) = ".lnk") then ' look only at the end of the string
  232. bIsAshortcut = true
  233. ' msgbox ">" & objFile.name & "<"
  234. else ' something had .lnk embedded but not at the end
  235. if instr(sObjFileName,".lnk") > 0 then
  236. msgbox strDirectory & vbcr & ">" & objFile.name & "<" & vbcr & s'? who has lnk not at end of name
  237. end if
  238. end if
  239.  
  240.  
  241.  
  242.  
  243.  
  244. if bIsAshortcut Then
  245. dim lnk
  246. dim filePath
  247. filepath = strDirectory & "" & objFile.name
  248. ' ms "128 have an lnk file " & vbcr & filePath
  249. dim hotKey
  250. set lnk = objShell.CreateShortcut(filepath)
  251. errSav2 = err.number
  252. hotKey = lnk.hotkey
  253. if hotKey <> "" then
  254. ';ms "129" & vbcr & "errSav2:" & errSav2 & vbcr & "hotKey:" & hotKey
  255. HotKeyCount = HotKeyCount + 1
  256. if len(lnkString) > 900 then
  257. msgbox len(lnkString) & vbcr & lnkString
  258. lnkString = ""
  259. end if
  260. if instr(lnkString,strDirectory & " | ") = 0 then
  261. lnkString = lnkString & vbcr & vbcr & "-" & vbcr & strDirectory & " | " ' put blank and bar on the end to differentiate sub directories
  262. else
  263. end if
  264. lnkString = lnkString & vbcr & HotKeyCount & " " & hotKey & " " & objFile.name
  265. 'ms "138" & lnkString
  266. ' save to text file
  267. end if
  268. END IF
  269. on error resume next
  270.  
  271. NEXT
  272.  
  273. END IF
  274.  
  275.  
  276. END SUB
  277.  
  278.  
  279. sub ms(BYVAL m)
  280. ' rc = msgbox ( "recurseCount:"&recurseCount & vbcr & vbcr & m , vbcrOKCancel)
  281. rc = msgbox ( m , vbOKCancel)
  282. if rc = vbCancel then wscript.quit
  283.  
  284. end sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement