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

Replies to VB Script Main 0101 21:01 rss

Title Name Language When
VB Script Main 0101 21:13 Newz vb 1 Year ago.