#163893 - 2006-06-30 07:39 PM
Determine the CD Drive
|
cmarti
Hey THIS is FUN
Registered: 2001-02-26
Posts: 297
Loc: Little Rock, AR
|
I've compiled a kixtart script into an exe using kixscript editor, I know I'm behind the time , This script is being put on a cd where I'm going to run the script from. The problem is I need to know what drive the cd is in. When I run the compiled exe the script dir is my temp folder.
I have an application that I need to install from the cd and would like to kick the application off from the script. How can I determine what the cd drive is if the @scriptdir gives me back the temp directory.
Here's my code: Code:
? @ScriptDir
Here's my output: Quote:
C:\DOCUME~1\CMARTI~1\LOCALS~1\Temp
Thanks in advance..
|
|
Top
|
|
|
|
#163895 - 2006-06-30 08:35 PM
Re: Determine the CD Drive
|
cmarti
Hey THIS is FUN
Registered: 2001-02-26
Posts: 297
Loc: Little Rock, AR
|
Thanks Doc, I'll check this out...
|
|
Top
|
|
|
|
#163898 - 2006-07-03 10:00 AM
Re: Determine the CD Drive
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Here is an example of how to do it. The findVolume() UDF will return the first drive whose title starts with the volume name passed to it.
Note, I have deliberately *not* restricted this to CD drives. This means that you can network map a dummy drive letter with the correct label for testing.
In this example the script looks for a drive with a label starting "MyDrive". If it doesn't find one it defaults to "C:"
Code:
Break ON $=SetOption("Explicit","ON") Dim $sDrive $sDrive=findVolume("MyDrive") If $sDrive="" $sDrive="C:" Endif "Will use drive letter "+$sDrive+@CRLF Function findVolume($sVolume) Dim $oFSO, $oDrive $findVolume="" $oFSO=CreateObject("Scripting.FileSystemObject") If Not @ERROR AND VarType($oFSO)=9 For Each $oDrive In $oFSO.Drives If InStr($oDrive.VolumeName,$sVolume)=1 $findVolume=$oDrive.DriveLetter+":" Exit 0 EndIf Next EndIf Exit 15 EndFunction
|
|
Top
|
|
|
|
#163899 - 2006-08-01 07:27 PM
Re: Determine the CD Drive
|
cmarti
Hey THIS is FUN
Registered: 2001-02-26
Posts: 297
Loc: Little Rock, AR
|
Thanks for all the replies, here's what I ended up doing..
Code:
$FileSystemObject = CreateObject("Scripting.FileSystemObject")
? "@CRLFSearching for CD drive..." $Drives = GetObject("winmgmts:").ExecQuery("select Name,DriveType from Win32_LogicalDisk where DriveType = 5") If @Error <> 0 ? "Unable to determine the CD drive letter." ? "Please enter the drive letter of the CD Drive." ? "Enter the drive letter in this format: D:@CRLF" Gets $CDRom Else For Each $Drive In $Drives $Count = 1 + $Count $CDROM = "$CDROM " + $Drive.Name Next $CDROM = Right($CDROM,Len($CDROM) - 1 ) If $Count > 1 $Drv = "drives" Else $Drv = "drive" EndIf ? " Found CDRom drive $CDROM." EndIf
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
1 registered
(Allen)
and 675 anonymous users online.
|
|
|