Jump to content
Sign in to follow this  
AlienStar

Eject CD-Rom .....

Recommended Posts

AlienStar

hello everybody

I have this script to eject a cdrom in any windows which detect by itself and you don't have to put the name of drive

$var = DriveGetDrive( "CDROM" )
If not @error Then
For $i = 1 to $var[0]
CDTray($var[$i] , "open")
Next
EndIf

but if someone has two cdroms they both open when I start this script

now :

I wanna eject the cdrom which contain the script so I used this :

$var = DriveGetDrive( "CDROM" )
If not @error Then
For $i = 1 to $var[0]
CDTray($var[$i] , "open" & @ScriptDir)
Next
EndIf

but it didn't work

please help ...................

Share this post


Link to post
Share on other sites
Paulie

Your script opens all the drives that are CDROMs because of the For...Next loop.

$var = DriveGetDrive( "CDROM" )
If not @error Then
For $i = 1 to $var[0]
CDTray($var[$i] , "open")
Next
EndIf

To open the drive that contains the script i would probably do this.

$drive = StringLeft(@ScriptFullPath,2) 
If DriveGetType($Drive&"\") = "CDROM" Then CDTray($Drive,"Open")

Share this post


Link to post
Share on other sites
AlienStar

thanks so much Paulie

it works ...

>_<

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.