Page 2 of 2 <12
Topic Options
#26000 - 2002-07-30 06:16 PM Re: YAMD Function Help!
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
like said it was workaround.
first, it still stops after the seconds.
also, the correct way would be:
IF (@ERROR OR $RC="") and $TIMEOUT<5

but when there is short timeout I would go with:
IF $RC="" and $TIMEOUT<5

cheers...
_________________________
!

download KiXnet

Top
#26001 - 2002-07-31 10:56 PM Re: YAMD Function Help!
KIXKicks Offline
Starting to like KiXtart

Registered: 2002-07-26
Posts: 177
Loc: Vancouver, WA
Lonkero,

If may not be the best...but here is the code for the WinXP part of the YAMD Function. It does not change icon however, I am not sure if XP even allows that.

code:
FUNCTION YAMD($DRIVELETTER, $UNC, optional $LABEL, optional $ICON, optional $DELETE)
DIM $DI, $HEXCHAR, $HEXLABEL, $LABELKEY, $LABELPATH, $LOOP, $OS, $SUBCMD, $TIMEOUT, $UNCASCCHAR, $UNCASCLABEL

$TIMEOUT=0
$LABELPATH=""
$DI="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons"
$LABELKEY="HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer"

SELECT
CASE @PRODUCTTYPE = "Windows XP Professional" $OS="WinXP" $SUBCMD="NET USE"
CASE @PRODUCTTYPE = "Windows 2000 Professional" $OS="Win2K" $SUBCMD="NET USE"
CASE @PRODUCTTYPE = "Windows NT Workstation" $OS="WinNT" $SUBCMD="SUBST"
ENDSELECT

SHELL '%COMSPEC% /C $SUBCMD $DRIVELETTER: /D 1>NUL 2>&1'

IF $DELETE
IF $OS="Win2k"
$=DELTREE("$LABELKEY\MountPoints\$DRIVELETTER")
$=DELTREE("$DI\$DRIVELETTER")
RETURN
ENDIF
ENDIF

SHELL '%COMSPEC% /C $SUBCMD $DRIVELETTER: "$UNC" 1>NUL 2>&1'

IF EXIST("$DRIVELETTER:\")=0
RETURN
ENDIF

IF $OS="Win2k"
IF $ICON
$=ADDKEY("$DI\$DRIVELETTER")
$=ADDKEY("$DI\$DRIVELETTER\DEFAULTICON")
$=ADDKEY("$DI\$DRIVELETTER\DEFAULTLABEL")
$=WRITEVALUE("$DI\$DRIVELETTER\DEFAULTICON","","$ICON",REG_SZ)
$=WRITEVALUE("$DI\$DRIVELETTER\DEFAULTLABEL","","$LABEL",REG_SZ)
ELSE
$=DELTREE("$DI\$DRIVELETTER")
ENDIF

IF $LABEL
FOR $LOOP = 1 TO LEN($LABEL) ; ******* Parse the label and convert to hex string
$HEXCHAR=DECTOHEX(ASC(SUBSTR("$LABEL",$LOOP,1)))
$HEXLABEL=$HEXLABEL+$HEXCHAR+"00"
NEXT

WHILE LEN($HEXLABEL) < 128 ; ******* Buffer the hex string to 128 characters
$HEXLABEL=$HEXLABEL+"00"
LOOP

$RC=WRITEVALUE("$LABELKEY\MountPoints\$DRIVELETTER","BaseClass","Drive",REG_SZ)
$RC=WRITEVALUE("$LABELKEY\MountPoints\$DRIVELETTER\_LABELFROMREG","CACHE","$HEXLABEL",REG_BINARY)
SLEEP 5
$RC=WRITEVALUE("$LABELKEY\MountPoints\$DRIVELETTER\_LABELFROMREG","VERSION","3",REG_DWORD)
$RC=WRITEVALUE("$LABELKEY\MountPoints\$DRIVELETTER\_LABELFROMREG","CACHE","$HEXLABEL",REG_BINARY)
ENDIF

ENDIF

IF $OS="WinXP"
IF $LABEL
FOR $LOOP = 1 TO LEN($UNC)
$UNCASCCHAR=SUBSTR("$UNC",$LOOP,1)

IF $UNCASCCHAR="\"
$UNCASCCHAR="#"
ENDIF

$UNCASCLABEL=$UNCASCLABEL+$UNCASCCHAR
NEXT


$RC=WRITEVALUE("$LABELKEY\MountPoints2\$UNCASCLABEL","_LABELFROMREG","$LABEL",REG_SZ)

ENDIF

ENDIF

ENDFUNCTION

I have been trying to make the Win2K part work in our environment so that is why is not the same as in the UDF Library.

Top
#26002 - 2002-08-01 08:30 AM Re: YAMD Function Help!
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I have nothing to do with xp [Big Grin]
if some other oldie would check that imagestuff...
_________________________
!

download KiXnet

Top
#26003 - 2002-10-15 05:29 PM Re: YAMD Function Help!
colepete Offline
Lurker

Registered: 2002-10-15
Posts: 1
An interesting note, for those who have not noticed it. This script will map and label w2k drives without a hitch, only takes about 3 seconds a drive. However, it works fine only if there is already an explorer window open when the script is run. And then, you have to open a second explorer window for the change to take effect.
Top
Page 2 of 2 <12


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

Who's Online
0 registered and 484 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.052 seconds in which 0.023 seconds were spent on a total of 13 queries. Zlib compression enabled.

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