用vbscript实现隐藏任务栏图标的脚本

时间:2022-11-14 17:33:24
  1. Message = "To work correctly, the script will close" & vbCR  
  2.   Message = Message & "and restart the Windows Explorer shell." & vbCR  
  3.   Message = Message & "This will not harm your system." & vbCR & vbCR  
  4.   Message = Message & "Continue?"  
  5.   X = MsgBox(Message, vbYesNo, "Notice")  
  6.   If X = 6 Then  
  7.   On Error Resume Next  
  8.   Dim WSHShell, n, MyBox, p, t, errnum, vers  
  9.   Dim itemtype  
  10.   Dim enab, disab, jobfunc  
  11.   Set WSHShell = WScript.CreateObject("WScript.Shell")  
  12.   p = "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoTrayItemsDisplay"  
  13.   itemtype = "REG_DWORD"  
  14.   enab = "ENABLED"  
  15.   disab = "DISABLED"  
  16.   jobfunc = "Notification Icons are now "  
  17.   t = "Confirmation"  
  18.   Err.Clear  
  19.   n = WSHShell.RegRead (p)  
  20.   errnum = Err.Number  
  21.   if errnum <> 0 then  
  22.    WSHShell.RegWrite p, 0, itemtype  
  23.   End If  
  24.   If n = 0 Then  
  25.    n = 1  
  26.   WSHShell.RegWrite p, n, itemtype  
  27.   Mybox = MsgBox(jobfunc & disab & vbCR, 4096, t)  
  28.   ElseIf n = 1 then  
  29.    n = 0  
  30.   WSHShell.RegWrite p, n, itemtype  
  31.   Mybox = MsgBox(jobfunc & enab & vbCR, 4096, t)  
  32.   End If  
  33.   Set WshShell = Nothing  
  34.   On Error GoTo 0  
  35.   For Each Process in GetObject("winmgmts:"). _  
  36.    ExecQuery ("select * from Win32_Process where name='explorer.exe'")  
  37.    Process.terminate(0)  
  38.   Next  
  39.   MsgBox "Finished." & vbcr & vbcr , 4096, "Done"  
  40.   Else   
  41.   MsgBox "No changes were made to your system." & vbcr & vbcr, 4096, "User Cancelled"  
  42.   End If