#26001 - 2002-07-31 10:56 PM
Re: YAMD Function Help!
|
KIXKicks
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
|
|
|
|
#26003 - 2002-10-15 05:29 PM
Re: YAMD Function Help!
|
colepete
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
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 484 anonymous users online.
|
|
|