Advertisement
Guest User

Untitled

a guest
Oct 1st, 2016
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. @cScript.EXE //noLogo "%~f0?.WSF" //job:info %~nx0 %*
  2. @exit /b 0
  3.  
  4. <job id="info">
  5. <script language="VBScript">
  6. if WScript.Arguments.Count < 2 then
  7. WScript.Echo "No drive letter passed"
  8. WScript.Echo "Usage: "
  9. WScript.Echo " " & WScript.Arguments.Item(0) & " {LETTER|*}"
  10. WScript.Echo " * will eject all cd drives"
  11. WScript.Quit 1
  12. end if
  13. driveletter = WScript.Arguments.Item(1):
  14. driveletter = mid(driveletter,1,1):
  15.  
  16. Public Function ejectDrive (drvLtr)
  17. Set objApp = CreateObject( "Shell.Application" ):
  18. Set objF=objApp.NameSpace(&H11&):
  19. 'WScript.Echo(objF.Items().Count):
  20. set MyComp = objF.Items():
  21. for each item in objF.Items() :
  22. iName = objF.GetDetailsOf (item,0):
  23. iType = objF.GetDetailsOf (item,1):
  24. iLabels = split (iName , "(" ) :
  25. iLabel = iLabels(1):
  26.  
  27. if Ucase(drvLtr & ":)") = iLabel and iType = "CD Drive" then
  28. set verbs=item.Verbs():
  29. set verb=verbs.Item(verbs.Count-4):
  30. verb.DoIt():
  31. item.InvokeVerb replace(verb,"&","") :
  32. ejectDrive = 1:
  33. exit function:
  34.  
  35. end if
  36. next
  37. ejectDrive = 2:
  38. End Function
  39.  
  40. Public Function ejectAll ()
  41. Set objApp = CreateObject( "Shell.Application" ):
  42.  
  43. Set objF=objApp.NameSpace(&H11&):
  44. 'WScript.Echo(objF.Items().Count):
  45. set MyComp = objF.Items():
  46. for each item in objF.Items() :
  47. iType = objF.GetDetailsOf (item,1):
  48. if iType = "CD Drive" then
  49. set verbs=item.Verbs():
  50. set verb=verbs.Item(verbs.Count-4):
  51. verb.DoIt():
  52. item.InvokeVerb replace(verb,"&","") :
  53. end if
  54.  
  55. next
  56. End Function
  57. if driveletter = "*" then
  58. call ejectAll
  59. WScript.Quit 0
  60. end if
  61. result = ejectDrive (driveletter):
  62.  
  63. if result = 2 then
  64. WScript.Echo "no cd drive found with letter " & driveletter & ":"
  65. WScript.Quit 2
  66. end if
  67.  
  68. </script>
  69. </job>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement