From Newz, 1 Year ago, written in Visual Basic.
This paste is a reply to VB Script Main 0101 17:38 from Newz - view diff
Embed
  1. 'REMOVE 100% OF PINNED ITEMS AND ADD PINNED ITEMS:
  2.  
  3. 'Remove 100% Of Pinned Items:
  4. Set oShell = WScript.CreateObject ("WScript.Shell")
  5. oShell.run "cmd.exe /c copy ""C:\Users\User\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\Google Chrome.lnk"" ""C:\Users\User\Documents\Google Chrome.lnk"""
  6.  
  7. Set oShell = WScript.CreateObject ("WScript.Shell")
  8. oShell.run "cmd.exe /c del ""C:\Users\User\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\Google Chrome.lnk"""
  9.  
  10. Set objShell = CreateObject("Shell.Application")
  11. Set objFolder = objShell.Namespace("C:\Users\User\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar")
  12.  
  13. For Each objFolderItem in objFolder.Items
  14.   For Each objVerb in objFolderItem.Verbs
  15.     If Replace(objVerb.name, "&", "") = "Unpin from Taskbar" Then objVerb.DoIt
  16.   Next
  17. Next
  18.  
  19. Set oShell = WScript.CreateObject ("WScript.Shell")
  20. oShell.run "cmd.exe /c copy ""C:\Users\User\Documents\Google Chrome.lnk"" ""C:\Users\User\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\Google Chrome.lnk"""
  21.  
  22. 'Add Pinned Items:
  23. Set objShell = CreateObject("Shell.Application")
  24. Set oShell = CreateObject("WScript.Shell")
  25. Set ofso = CreateObject("Scripting.FileSystemObject")
  26.  
  27. strFile = "C:\Windows\System32\notepad.exe"
  28. PinToTaskBar
  29.  
  30. strFile = "C:\Windows\System32\cmd.exe"
  31. PinToTaskBar
  32.  
  33. strFile = "C:\Windows\explorer.exe"
  34. PinToTaskBar
  35.  
  36. sub PinToTaskBar
  37.  
  38. if ofso.fileexists(strFile) then
  39.    Set objFolder = objShell.Namespace(ofso.GetParentFolderName(strFile))
  40.    Set objFolderItem = objFolder.ParseName(ofso.GetFileName(strFile))
  41.    Set colVerbs = objFolderItem.Verbs
  42.    For Each objVerb in colVerbs
  43.       If Replace(objVerb.name, "&", "") = "Pin to Taskbar" Then objVerb.DoIt
  44.    Next
  45. End IF
  46.  
  47. End Sub
  48.  
  49. 'MAP FOLDERS TO SIDEBAR AS SUBSTITUTED DIRECTORIES:
  50. Set oShell = WScript.CreateObject ("WScript.Shell")
  51. oShell.run "cmd.exe /c subst V: C:\Users\User"
  52. Set oShell = WScript.CreateObject ("WScript.Shell")
  53. oShell.run "cmd.exe /c subst W: C:\Users\User\Documents"
  54. Set oShell = WScript.CreateObject ("WScript.Shell")
  55. oShell.run "cmd.exe /c subst X: C:\Users\User\Downloads"
  56. Set oShell = WScript.CreateObject ("WScript.Shell")
  57. oShell.run "cmd.exe /c subst Y: C:\"
  58.  
  59. WScript.Sleep 3000
  60.  
  61. 'Rename Drive Letters:
  62. Set oShell = WScript.CreateObject ("Shell.Application")
  63. oShell.NameSpace("V:\").Self.Name = "User (Home)"
  64. Set oShell = WScript.CreateObject ("Shell.Application")
  65. oShell.NameSpace("W:\").Self.Name = "Documents"
  66. Set oShell = WScript.CreateObject ("Shell.Application")
  67. oShell.NameSpace("X:\").Self.Name = "Downloads"
  68.  
  69. WScript.Sleep 3000
  70.  
  71. 'Special Code For Local Drive (C) (Mounted As Y:):
  72. Set oShell = WScript.CreateObject ("WScript.Shell")
  73. oShell.run "cmd.exe /c subst Y: C:\Users\User\Downloads"
  74.  
  75. Set oShell = WScript.CreateObject("Shell.Application")
  76. oShell.NameSpace("Y:\").Self.Name = "Local Drive (C)"
  77.  
  78. WScript.Sleep 3000
  79. Set WshShell = WScript.CreateObject("WScript.Shell")
  80. WshShell.SendKeys "{ENTER}"
  81.  
  82. Set oShell = WScript.CreateObject ("WScript.Shell")
  83. oShell.run "cmd.exe /c subst /d Y:"
  84. Set oShell = WScript.CreateObject ("WScript.Shell")
  85. oShell.run "cmd.exe /c subst Y: C:\"
  86.  
  87. '- - -
  88.  
  89. WScript.Sleep 3000
  90.  
  91. 'UNPIN AND PIN PROGRAMS TO TASKBAR & KILL VARIOUS TASKS:
  92.  
  93. 'Pin Programs To Taskbar
  94. Set oShell = WScript.CreateObject ("WScript.Shell")
  95. Set wsc = WScript.CreateObject("WScript.Shell")
  96. Set lnk = wsc.CreateShortcut("C:\Users\User\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\Command Prompt.lnk")
  97. lnk.targetpath = "C:\Windows\System32\cmd.exe"
  98. lnk.workingdirectory = "C:\Windows\System32"
  99. lnk.save
  100.  
  101. WScript.Sleep 3000
  102.  
  103. 'Kill Various Tasks
  104.  
  105. '>>>>>>>>>SEARCH THROUGH TASKS TO FIND MORE TO KILL
  106.  
  107. '<<<<<<<<<Set oShell = WScript.CreateObject ("WScript.Shell")
  108. '<<<<<<<<<set result=oShell.run "cmd.exe /c taskkill /f /im tvnserver.exe > nul 2>&1" 'TightVNC Tray Icon
  109. '<<<<<<<<<result=msgbox()
  110.  
  111. Set oShell = WScript.CreateObject ("WScript.Shell")
  112. oShell.run "cmd.exe /c taskkill /f /im pntray.exe" 'Dell vWorkspace Tray Icon
  113. Set oShell = WScript.CreateObject ("WScript.Shell")
  114. oShell.run "cmd.exe /c taskkill /f /im rthdvcpl.exe" 'Realtek Semiconductor High Definition Audio Tray Icon
  115. Set oShell = WScript.CreateObject ("WScript.Shell")
  116. oShell.run "cmd.exe /c taskkill /f /im mom.exe" 'Part Of AMD ATI Catalyst Control Center
  117. Set oShell = WScript.CreateObject ("WScript.Shell")
  118. oShell.run "cmd.exe /c taskkill /f /im ccc.exe" 'AMD ATI Catalyst Control Center Tray Icon
  119.  
  120. WScript.Sleep 5000
  121.  
  122. '>>>>>>>>>POSSIBLY LOG SUCCESS OF TASKS KILLED
  123.  
  124. 'Relaunch "Explorer.exe":
  125. Set oShell = WScript.CreateObject ("WScript.Shell")
  126. oShell.run "cmd.exe /c taskkill /f /im explorer.exe"
  127.  
  128. WScript.Sleep 4000
  129.  
  130. Set oShell = WScript.CreateObject ("WScript.Shell")
  131. oShell.run "cmd.exe /c copy ""C:\Windows\System32\cmd.exe"" ""Z:\bbb.exe"""
  132.  
  133. WScript.Sleep 2000
  134.  
  135. Set oShell = WScript.CreateObject ("WScript.Shell")
  136. oShell.run "Z:\bbb.exe /c C:\Windows\explorer"
  137.  
  138. WScript.Sleep 4000
  139.  
  140. Set oShell = WScript.CreateObject ("WScript.Shell")
  141. oShell.run "cmd.exe /c taskkill /f /im bbb.exe"
  142.  
  143. '>>>>>>>>>DELETE ALL CONTENTS OF Z DRIVE
  144.  
  145. 'Set oShell = WScript.CreateObject ("WScript.Shell")
  146. 'oShell.run "cmd.exe /c copy Z:\Z.vbs C:\Users\User\Documents\Z.vbs"
  147.  
  148. 'Set oShell = WScript.CreateObject ("WScript.Shell")
  149. 'oShell.run "cmd.exe /c del /S Z:\*"
  150.  
  151.  
  152. '>>>>>>>>>UPDATE CHROME (FIRST QUIT WINDOWS EXPLORER TO FREE UP RAM)
  153.  
  154. '>>>>>>>>>INSTALL CHROME EXTENSIONS
  155.  
  156. '>>>>>>>>>"shutdown /a" SHORTCUT ON TASKBAR OR AUTO-DETECT AND CANCEL WHEN SYSTEM WARNS ABOUT SHUTTING DOWN TO FREE MEMORY
  157.  
  158. '>>>>>>>>>MAKE THIS SCRIPT RUN IN BACKGROUND INSTEAD OF ON-SCREEN cmd.exe WINDOWS:
  159.  
  160. 'END OF SCRIPT USER NOTIFICATION:
  161. msgbox("The Script Completed Successfully")
  162.  
  163. '- - -
  164.  
  165. 'https://msdn.microsoft.com/en-us/library/5h27x7e9(v=vs.84).aspx
  166. '(If Then Single Line Syntax)
  167.  
  168. 'http://stackoverflow.com/questions/157747/vbscript-using-error-handling
  169. '(Error Handling)
  170.  
  171. '- - -
  172.  
  173. 'Clear output.txt
  174. 'echo( > C:\Users\User\Documents\output.txt
  175.  
  176. 'Find only lines with files
  177. 'dir Z:\ >> C:\Users\User\Documents\output.txt & for /f "delims=" %a in ('findstr /c:"M " C:\Users\User\Documents\output.txt') do @set var=%a & echo( > C:\Users\User\Documents\output.txt & echo %a > C:\Users\User\Documents\output.txt
  178.  
  179. 'Output number of lines
  180. 'for /f "delims=" %a in ('find /v /c "" C:\Users\User\Documents\output.txt') do @set var=%a & @echo %var:~47%