Page 1 of 1 1
Topic Options
#163893 - 2006-06-30 07:39 PM Determine the CD Drive
cmarti Offline
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
#163894 - 2006-06-30 08:25 PM Re: Determine the CD Drive
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
Well from Rob van der Woude's site here is a batch method for XP.

http://www.robvanderwoude.com/files/cdactxp.txt


I'm sure there may be other methods - just Google around a bit if this doesn't work out for you.

Here is another method as well...
http://www.fpschultze.de/smartfaq+faq.faqid+62.htm


Edited by NTDOC (2006-06-30 08:32 PM)

Top
#163895 - 2006-06-30 08:35 PM Re: Determine the CD Drive
cmarti Offline
Hey THIS is FUN

Registered: 2001-02-26
Posts: 297
Loc: Little Rock, AR
Thanks Doc, I'll check this out...
Top
#163896 - 2006-07-01 02:27 PM Re: Determine the CD Drive
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
USE WMI to enumerate the drives, filtering for CD drives. However, the better approach would be to enumerate the processes, specifically the .EXE process that you started from the CD and that contains the KiXtart script. The path to that .EXE will then give you the correct drive letter and prevent potential false-positives in case of multiple CD-drives on a computer.
_________________________
There are two types of vessels, submarines and targets.

Top
#163897 - 2006-07-03 09:21 AM Re: Determine the CD Drive
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Can you get the drive label from the WMI enumeration?

If so, enumerate the drives and use the one that is labelled "MyDiscV1.0" or whatever you intend to label the disc.

Top
#163898 - 2006-07-03 10:00 AM Re: Determine the CD Drive
Richard H. Administrator Offline
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 Offline
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
#163900 - 2006-08-02 04:57 AM Re: Determine the CD Drive
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
So, then why not enhance it and check the identified CD drives for the CD you're using. I assume the .EXE has some kind of standard name that you could then use to distinguish between multiple CD in multiple CD drives.
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1376 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.063 seconds in which 0.031 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org