Page 1 of 1 1
Topic Options
#51024 - 2000-08-16 02:31 PM CD or not?
Anonymous
Unregistered


This nice loop checks if a drive is free in the string $LETTERS and returns the var $FREELETTER

But if you set $LETTERS to "XYZ" and X is a CD without a CD-Rom the "if exist..." returns that it's free.

Any ideas of workaround?

:CHKDRIVES
$i = 1
while $i < len($LETTERS)+1
$tkn=substr($LETTERS, $i, 1)
if exist($TKN + ":\nul")
else
$FREELETTER = $TKN
return
endif
$i=$i+1
loop
return


The use of it is in a script that mounts a free letter to a network-share, and if X is a CD you will get a error 85.

------------------
--
rikard.ronnkvist@martinsson.se

Top
#51025 - 2000-08-16 04:16 PM Re: CD or not?
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
I am only assuming that you are doing this for drive mapping?.....

why not use the * for next available drive letter?

use * "\\server\share\"

Here is a bit of code that reports what network drives are in use, it uses output from the "net use" command. Also note that the way it builds $report by using separate $drive and $share variables.

code:

$cr = chr(13) + chr(10)
$report = ""
shell '%comspec% /c net use | find /i ":" > temp.dat'
$q = open(1,"temp.dat",2)
$line = readline(1)
do
$drive = substr("$line",14,2)
$share = substr("$line",24,26)
$report = $report + "$drive = $share$cr"
$line = readline(1)
until @error <> 0
$q = close(1) del "temp.dat"

? $report
$q = messagebox("$report","Drives in use",64)


Bryce

[This message has been edited by Bryce (edited 16 August 2000).]

Top
#51026 - 2000-08-17 08:19 AM Re: CD or not?
Anonymous
Unregistered


I need to know witch drive it is, and I need to use one of VWXYZ.

Top
#51027 - 2000-08-18 12:36 AM Re: CD or not?
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

additional to Bryce code you must also check which drive letters are
locally mapped. so you don't want a direct read request to a cdrom
drive without a cdrom in it.
the information of cdrom are available by your registry. they must not only
tell: have I a cdrom drive?, but also which drive-letter has
been assigned to it.

for Windows9x you can get the information by reading the registry
key: "HKEY_LOCAL_MACHINE\Enum\SCSI".
it gives you an answer not only about cdrom drives but also other
disk-drives.

for Windows NT you only can get the information about cdrom drives,
because the disk-drive information can not be read by a kixtart
command. the HKCC contains those information.

code:

IF setconsole("hide")
ENDIF
;
; NT/95 logging - Kixtart 3.62
;
; (c) scripting@wanadoo.nl - 2000
;
; 1.00 (20000815) original version - read disk/cdrom information
;
$debug_mode="yes"
IF ($debug_mode = "yes")
IF (RedirectOutput("kix-info.txt",1) = 0)
ENDIF
ENDIF
;
IF (@inwin = 1)
$NT_mode="yes"
ELSE
$NT_mode="no"
ENDIF
;
$fix_disk=""
$fix_cdrom=""

; ----- HKLM hardware configuration - local hardware - 95 -----

$execute_mode="yes"
IF ($NT_mode = "yes")
$execute_mode="no"
ENDIF
IF ($execute_mode = "yes")
$ikey="HKEY_LOCAL_MACHINE\Enum\SCSI" ; - 95 -
IF (ExistKey($ikey) = 0)
$completed="no"
$index=0
DO
$icode=ENUMKEY($ikey, $index)
IF (@error = 0)
IF ($debug_mode = "yes")
? $ikey+"\"+$icode
ENDIF
IF (len($icode) <> 0)
$completed1="no"
$index1=0
$ikey1=$ikey+"\"+$icode
DO
$icode1=ENUMKEY($ikey1, $index1)
IF (@error = 0)
$ikey2=$ikey1+"\"+$icode1
$icode2=ReadValue($ikey2, "Class")
IF (@error = 0)
ENDIF
IF (len($icode2) <> 0)
IF ($debug_mode = "yes")
? " Class ="+$icode2
ENDIF
IF (LCASE($icode2) = "cdrom")
$fix_cdrom=$fix_cdrom+ReadValue($ikey2, "CurrentDriveLetterAssignment")
ENDIF
$icode2=ReadValue($ikey2, "CurrentDriveLetterAssignment")
IF (@error = 0)
ENDIF
IF (len($icode2) <> 0)
IF ($debug_mode = "yes")
? " CurrentDriveLetterAssignment="+$icode2
ENDIF
ENDIF
$icode2=ReadValue($ikey2, "UserDriveLetterAssignment")
IF (@error = 0)
ENDIF
IF (len($icode2) <> 0)
IF ($debug_mode = "yes")
? " User DriveLetterAssignment="+$icode2
ENDIF
ENDIF
$icode2=ReadValue($ikey2, "DeviceDesc")
IF (@error = 0)
ENDIF
IF (len($icode2) <> 0)
IF ($debug_mode = "yes")
? " DeviceDesc ="+$icode2
ENDIF
ENDIF
$icode2=ReadValue($ikey2, "IDEMaster")
IF (@error = 0)
ENDIF
IF (len($icode2) <> 0)
IF ($debug_mode = "yes")
? " IDEMaster ="+$icode2
ENDIF
ENDIF
ENDIF
ELSE
$completed1="yes"
ENDIF
$index1=$index1+1
UNTIL ($completed1 = "yes")
ENDIF
ELSE
$completed="yes"
ENDIF
$index=$index+1
UNTIL ($completed = "yes")
ENDIF

; ----- HKLM hardware configuration - local hardware - NT -----

$ikey="HKEY_LOCAL_MACHINE\Enum\ESDI" ; - 95 -
IF (ExistKey($ikey) = 0)
$completed="no"
$index=0
DO
$icode=ENUMKEY($ikey, $index)
IF (@error = 0)
IF ($debug_mode = "yes")
? $ikey+"\"+$icode
ENDIF
IF (len($icode) <> 0) AND (INSTR(LCASE($icode),"generic") <> 0)
$completed1="no"
$index1=0
$ikey1=$ikey+"\"+$icode
DO
$icode1=ENUMKEY($ikey1, $index1)
IF (@error = 0)
$ikey2=$ikey1+"\"+$icode1
$icode2=ReadValue($ikey2, "Class")
IF (@error = 0)
ENDIF
IF (len($icode2) <> 0)
IF ($debug_mode = "yes")
? " Class ="+$icode2
ENDIF
IF (LCASE($icode2) = "diskdrive")
$fix_disk=$fix_disk+ReadValue($ikey2, "CurrentDriveLetterAssignment")
ENDIF
$icode2=ReadValue($ikey2, "CurrentDriveLetterAssignment")
IF (@error = 0)
ENDIF
IF (len($icode2) <> 0)
IF ($debug_mode = "yes")
? " CurrentDriveLetterAssignment="+$icode2
ENDIF
ENDIF
$icode2=ReadValue($ikey2, "UserDriveLetterAssignment")
IF (@error = 0)
ENDIF
IF (len($icode2) <> 0)
IF ($debug_mode = "yes")
? " User DriveLetterAssignment="+$icode2
ENDIF
ENDIF
$icode2=ReadValue($ikey2, "DeviceDesc")
IF (@error = 0)
ENDIF
IF (len($icode2) <> 0)
IF ($debug_mode = "yes")
? " DeviceDesc ="+$icode2
ENDIF
ENDIF
$icode2=ReadValue($ikey2, "IDEMaster")
IF (@error = 0)
ENDIF
IF (len($icode2) <> 0)
IF ($debug_mode = "yes")
? " IDEMaster ="+$icode2
ENDIF
ENDIF
ENDIF
ELSE
$completed1="yes"
ENDIF
$index1=$index1+1
UNTIL ($completed1 = "yes")
ENDIF
ELSE
$completed="yes"
ENDIF
$index=$index+1
UNTIL ($completed = "yes")
ENDIF
$fix_cdrom=LCASE($fix_cdrom)
$fix_disk=LCASE($fix_disk)
IF ($debug_mode = "yes")
? " summary: User Disk ="+$fix_disk
? " CDrom="+$fix_cdrom
ENDIF
IF (len($fix_disk) <> 0)
? "disk=("+$fix_disk+")"
ELSE
? "disk=(?)"
ENDIF
IF (len($fix_cdrom) <> 0)
? "cdrom=("+$fix_cdrom+")"
ELSE
? "cdrom=(?)"
ENDIF
ENDIF

; ----- HKLM services configuration - NT -----

; - CDrom active ? - NT: IDE / remark: disk-drives only locatable by HKCC registry. not readable by kixtart -

$execute_mode="yes"
IF ($NT_mode <> "yes")
$execute_mode="no"
ENDIF
IF ($execute_mode = "yes")
IF ($NT_mode = "yes")
$ikey="HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\Root\LEGACY_CDROM\0000\Control"
IF (ExistKey($ikey) = 0) ; - NT -
$ivalue=ReadValue($ikey, "ActiveService")
IF (@error = 0)
;
$ikey="HKEY_LOCAL_MACHINE\SYSTEM\DISK"
IF (ExistKey($ikey) = 0)
$ivalue=ReadValue($ikey, "\Device\CdRom0")
IF (@error = 0)
$fix_cdrom=LCASE(substr($ivalue,1,1))
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
;
IF (len($fix_cdrom) <> 0)
? "cdrom=("+$fix_cdrom+")"
ELSE
? "cdrom=(?)"
ENDIF
ENDIF


Information created by $debug_mode="yes" on windows 9x:

code:

HKEY_LOCAL_MACHINE\Enum\SCSI\MATSHITACD-R___CW-7501__1
Class =CDROM
CurrentDriveLetterAssignment=J
User DriveLetterAssignment=JJ
DeviceDesc =Philips CD-R
HKEY_LOCAL_MACHINE\Enum\SCSI\IOMEGA__ZIP_100_________2
Class =DiskDrive
CurrentDriveLetterAssignment=X
User DriveLetterAssignment=XX
DeviceDesc =IOMEGA ZIP 100
HKEY_LOCAL_MACHINE\Enum\ESDI\GENERIC_IDE__DISK_TYPE47_
Class =DiskDrive
CurrentDriveLetterAssignment=CE
DeviceDesc =GENERIC IDE DISK TYPE47
IDEMaster =01
Class =DiskDrive
CurrentDriveLetterAssignment=DF
DeviceDesc =GENERIC IDE DISK TYPE47
HKEY_LOCAL_MACHINE\Enum\ESDI\VIRTUAL__CD-ROM_DRIVE____
summary: User Disk =cedf
CDrom=j
disk=(cedf)
cdrom=(j)


code available also on http://home.wanadoo.nl/scripting

Greetings.

[This message has been edited by MCA (edited 17 August 2000).]

_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

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 1471 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.132 seconds in which 0.108 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