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

Replies to Re: VB Script Main 0101 21:58 rss

Title Name Language When
wGynSnVPfAuuKYhW Barnypok vb 1 Year ago.
Re: Re: VB Script Main 0101 21:58 Mature Pudu vb 1 Year ago.