Guest User

Untitled

a guest
May 27th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Const ssfCONTROLS = 3
  2.  
  3. sConnectionName = "本地连接"
  4.  
  5. sEnableVerb = "启用(&A)"
  6. sDisableVerb = "停用(&B)"
  7. Set objShell = CreateObject("Wscript.Shell")
  8.  
  9. set shellApp = createobject("shell.application")
  10. set oControlPanel = shellApp.Namespace(ssfCONTROLS)
  11.  
  12. set oNetConnections = nothing
  13.  
  14. for each folderitem in oControlPanel.items
  15.     if folderitem.name = "网络连接" then
  16.         set oNetConnections = folderitem.getfolder: exit for
  17.     end if
  18. next
  19.  
  20. if oNetConnections is nothing then
  21.     wscript.quit
  22. end if
  23.  
  24. set oLanConnection = nothing
  25. for each folderitem in oNetConnections.items
  26.     if lcase(folderitem.name) = lcase(sConnectionName) then
  27.         set oLanConnection = folderitem: exit for
  28.     end if
  29. next
  30.  
  31. if oLanConnection is nothing then
  32.     wscript.quit
  33. end if
  34.  
  35. bEnabled = true
  36. set oEnableVerb = nothing
  37. set oDisableVerb = nothing
  38. s = "Verbs: " & vbcrlf
  39. for each verb in oLanConnection.verbs
  40.     s = s & vbcrlf & verb.name
  41.     if verb.name = sEnableVerb then
  42.         set oEnableVerb = verb
  43.         bEnabled = false
  44.     end if
  45.     if verb.name = sDisableVerb then
  46.         set oDisableVerb = verb
  47.         iReturnCode=objShell.Run("rundll32.exe user32.dll,LockWorkStation",0,TRUE)
  48.     end if
  49. next
  50.  
  51.  
  52. if bEnabled then
  53.     oDisableVerb.DoIt
  54. else
  55.     oEnableVerb.DoIt
  56. end if
  57.  
  58. wscript.sleep 1000
Add Comment
Please, Sign In to add comment