Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sub help
- wscript.echo "Usage:" & vbcrlf _
- & vbcrlf & " DevEject /list" _
- & vbcrlf & " List ejectable devices." & vbcrlf _
- & vbcrlf & " DevEject /eject {device name}" _
- & vbcrlf & " Eject specified device."
- wscript.quit 1
- end sub
- if wscript.arguments.count = 0 then help
- cmd = -1
- s = ucase(wscript.arguments(0))
- if s = "/EJECT" then
- cmd = 1
- if wscript.arguments.count = 1 then help
- name = ucase(wscript.arguments(1))
- elseif s = "/LIST" then
- cmd = 0
- else
- help
- end if
- set sa = createobject("shell.application")
- set fd = sa.namespace("::{26EE0668-A00A-44D7-9371-BEB064C98683}\0\::{A8A91A66-3A7D-4424-8D24-04E180695C7A}")
- if fd is nothing then
- wscript.echo "This script requires administrator rights."
- wscript.quit 2
- end if
- cnt = 0
- if cmd = 0 then 'list
- for each fi in fd.items
- for each vi in fi.verbs
- if vi.name = "&Eject" then
- cnt = cnt + 1
- wscript.echo fi.name
- exit for
- end if
- next
- next
- if cnt = 0 then wscript.echo "No ejectable device found."
- else 'eject
- for each fi in fd.items
- if ucase(fi.name) = name then
- cnt = 1
- for each vi in fi.verbs
- if vi.name = "&Eject" then
- vi.doit
- wscript.echo "Ejected " & fi.name & "."
- wscript.quit
- end if
- next
- end if
- next
- if cnt > 0 then
- wscript.echo "Specified device is not ejectable."
- else
- wscript.echo "Specified device is not found."
- end if
- end if
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement