• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Eject a Zip Disk

M

Mesan

#1
I've been searching for a long time for a way to eject a zip disk from
within a powershell script but haven't been able to find anything.

I finally came across the Removable Storage Manager (rsm.exe) utility
and found a way to make it work.

This is what it takes on my machine with just a single internal IDE
Zip-100, so you may have to modify things a bit, but this at least
gives you the framework of what to do.

I'm very much open to suggestions for how this can be improved, it's a
very crude approach I'm sure.

__________________________________________________________________________

# Refresh removable storage
# NOTE: That's MY guid - yours is probably different, so run "rsm
view /tmedia_type /guiddisplay" and find your guid for "Removable
Media"
rsm refresh /tgf5ed678de1c342c1a6833f0cc16b700c

# Get the friendly name of the zip disk
rsm view /tphysical_media /b > out.txt
$friendly_name = get-content out.txt
# At least on my computer the output was 2 lines - a blank line
followed by the friendly name that I wanted
$friendly_name = $friendly_name[1]

# Eject the zip disk
rsm eject /pf"$friendly_name"
 

My Computer

D

dreeschkind

#2
Hi Mesan, thanks for sharing this. I think I can use this for my iPod. :-)
I modyfied your code a little bit so that the script selects the right guid
based on the media type name that you specify. Note that the name needs to be
localized. For example on my German WinXP 'Removable Media' is called
'Wechselmedien'.
I also removed the use of the temporary file. You can redirect the standard
output directly to a variable instead.

####################################
$guid = rsm view /tmedia_type /guiddisplay | select-string 'Removable Media'
| foreach { $_.line.substring($_.line.length-32, 32) }

rsm refresh /tg$guid

$friendly_name = rsm view /tphysical_media /b | select-string 'DREESCHPOD' |
foreach {$_.line}

rsm eject /pf$friendly_name
####################################

--
greetings
dreeschkind

"Mesan" wrote:

> I've been searching for a long time for a way to eject a zip disk from
> within a powershell script but haven't been able to find anything.
>
> I finally came across the Removable Storage Manager (rsm.exe) utility
> and found a way to make it work.
>
> This is what it takes on my machine with just a single internal IDE
> Zip-100, so you may have to modify things a bit, but this at least
> gives you the framework of what to do.
>
> I'm very much open to suggestions for how this can be improved, it's a
> very crude approach I'm sure.
>
> __________________________________________________________________________
>
> # Refresh removable storage
> # NOTE: That's MY guid - yours is probably different, so run "rsm
> view /tmedia_type /guiddisplay" and find your guid for "Removable
> Media"
> rsm refresh /tgf5ed678de1c342c1a6833f0cc16b700c
>
> # Get the friendly name of the zip disk
> rsm view /tphysical_media /b > out.txt
> $friendly_name = get-content out.txt
> # At least on my computer the output was 2 lines - a blank line
> followed by the friendly name that I wanted
> $friendly_name = $friendly_name[1]
>
> # Eject the zip disk
> rsm eject /pf"$friendly_name"
>
>
 

My Computer

Users Who Are Viewing This Thread (Users: 1, Guests: 0)