Jump to content

Eject CD-Rom .....


Recommended Posts

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 ...................

Link to comment
Share on other sites

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")
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...