#66187 - 2002-06-06 04:10 PM
Re: My logon Script (caution long lines and post)
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
This script is called from the main code for customization for a specific office/location
code:
select case ingroup($group+"med") MapPrinter("\\a06\Elton",1) case ingroup($group+"hqa") case ingroup($group+"mis") MapPrinter("\\wheelerc\printer",1) case ingroup($group+"mqa") MapPrinter("\\a06\barbrady",1) case ingroup($group+"oig") MapPrinter("\\a06\elton",1) use e: "\\fdhctlh03\fmmiscsr" case 1 sendmessage("@userid","No H: or S: drive will be mapped") sendmessage("$dcsa","No H: or S: drive was mapped on @userid") endselect
$h="$server\$dept\home\@userid" $s="$server\$dept\shared"
if ingroup($group+"mis") $s="$setup" $h="$server\medicaid\home\@userid" endif
if exist("$h")=0 md "$h" if @error=0 $=sendmessage("$dcsa","Home Folder created at $h for @userid") ; For the cacls statements below to work the user must have ; the CHANGE PERMISSION permission on the home folder root shell "%comspec% /c echo y| cacls $h /t /c /g fdhc\@userid:c" shell '%comspec% /c echo y| cacls $h /t /e /c /g "fdhc\domain admins:f"' shell "%comspec% /c echo y| cacls $h /t /e /c /g fdhc\$group"+"mis:c" else $=sendmessage("$dcsa","Home Folder was NOT created at $h for @userid") endif endif
select case $os="WinNT" $subcmd="subst" case $os="Win2k" $subcmd="net use" endselect
? " Connecting "color c+/n"H: "color w/n"to "color w+/n $h color w/n shell "CMD /c $subcmd h: /d 1>Nul 2>&1" shell "CMD /c $subcmd h: $h 1>Nul 2>&1"
? " Connecting "color c+/n"S: "color w/n"to "color w+/n $s color w/n shell "CMD /c $subcmd s: /d 1>Nul 2>&1" shell "CMD /c $subcmd s: $s 1>Nul 2>&1"
if @userid="mcgowann" use p: "\\c1dm3\pharmacy" endif
;******************************************************************* function MapPrinter($printer, Optional $default, optional $oldspool) DIM $index,$IsInstalled,$lptprinter,$inst_printers,$PrinterPorts,$port_type $index=0 $IsInstalled=0 $lptprinter=0 $PrinterPorts="HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\PrinterPorts"
if $oldspool $=DelPrinterConnection($oldspool) endif :loopprinters $inst_printers=enumvalue($PrinterPorts,$index) $port_type=readvalue("$PrinterPorts\$inst_printers","$printer") if @error=0 if $printer=$inst_printers $IsInstalled=1 endif if instr("$port_type","LPT") $lptprinter=1 endif $index=$index+1 goto loopprinters endif if $IsInstalled=0 $=AddPrinterConnection("$printer") endif if $IsInstalled=0 and $lptprinter=0 and $default $=SetDefaultPrinter("$printer") endif endfunction
;******************************************************************* Function MapDrive($DriveLetter, $UNC, optional $Label, optional $Icon, optional $Delete) dim $hexchar, $hexlabel, $loop, $subcmd, $os, $labelkey, $keyarray, $labelpath, $di, $timeout
$timeout=0 $labelpath="" $di="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons" $labelkey="HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints"
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 $=deltree("$labelkey\$DriveLetter") $=deltree("$di\$DriveLetter") return endif shell '%comspec% /c $subcmd $DriveLetter: "$UNC" 1>Nul 2>&1' if exist("$DriveLetter:\")=0 return endif
if $os="Win2k" 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 :waitforreg ; ******* Wait for windows to create the reg keys $rc=readvalue("$labelkey\$DriveLetter\_LabelFromReg","Cache") if @error or $rc="" or $timeout<5 $timeout=$timeout+1 sleep(1) goto waitforreg endif $rc=writevalue("$labelkey\$DriveLetter\_LabelFromReg","Version","3",REG_DWORD) $rc=writevalue("$labelkey\$DriveLetter\_LabelFromReg","Cache","$hexlabel",REG_BINARY) endif if $icon ; ******* Maintain custom 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 endif if $os="winxp" ;eventually I will add winxp support... endif endfunction
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 764 anonymous users online.
|
|
|