#203279 - 2011-10-17 09:37 PM
This script is too long!!!
|
dgraham
Fresh Scripter
Registered: 2006-04-11
Posts: 39
Loc: Santa Fe, New Mexico
|
Hey guys. Was hoping someone out there could lend me the benefit of experience. I have a logon script that just keeps growing. It's over 16 pages now and I worry it's taking too long to run at remote sites with slow bandwidth. A huge part of it is taken up with repetitive drive mappings. (An excerpt is below) It seems so inelegant and innefficient to me. Not sure what I can do about it though. Any suggestions?
Thanks for reading!
Select
;Districts
Case InGroup ('Domain\D1_Employee','Domain\D1_Super')
Use "L:" '\\NAS\Users\District\D1' /Persistent
Use "X:" '\\FileServer\DigitalAudio\District1' /Persistent
Use "Y:" '\\FileServer\SavedAudio\District1' /Persistent
Case InGroup ('Domain\D2_Employee','Domain\D2_Super')
Use "L:" '\\NAS\Users\District\D2' /Persistent
Use "X:" '\\FileServer\DigitalAudio\District2' /Persistent
Use "Y:" '\\FileServer\SavedAudio\District2' /Persistent
Case InGroup ('Domain\D3_Employee','Domain\D3_Super')
Use "L:" '\\NAS\Users\District\D3' /Persistent
Use "X:" '\\FileServer\DigitalAudio\District3' /Persistent
Use "Y:" '\\FileServer\SavedAudio\District3' /Persistent
Case InGroup ('Domain\D4_Employee','Domain\D4_Super')
Use "L:" '\\NAS\Users\District\D4' /Persistent
Use "X:" '\\FileServer\DigitalAudio\District4' /Persistent
Use "Y:" '\\FileServer\SavedAudio\District4' /Persistent
Case InGroup ('Domain\D5_Employee','Domain\D5_Super')
Use "L:" '\\NAS\Users\District\D5' /Persistent
Use "X:" '\\FileServer\DigitalAudio\District5' /Persistent
Use "Y:" '\\FileServer\SavedAudio\District5' /Persistent
Case InGroup ('Domain\D6_Employee','Domain\D6_Super')
Use "L:" '\\NAS\Users\District\D6' /Persistent
Use "X:" '\\FileServer\DigitalAudio\District6' /Persistent
Use "Y:" '\\FileServer\SavedAudio\District6' /Persistent
Case InGroup ('Domain\D7_Employee','Domain\D7_Super')
Use "L:" '\\NAS\Users\District\D7' /Persistent
Use "X:" '\\FileServer\DigitalAudio\District7' /Persistent
Use "Y:" '\\FileServer\SavedAudio\District7' /Persistent
Case InGroup ('Domain\D8_Employee','Domain\D8_Super')
Use "L:" '\\NAS\Users\District\D8' /Persistent
Use "X:" '\\FileServer\DigitalAudio\District8' /Persistent
Use "Y:" '\\FileServer\SavedAudio\District8' /Persistent
Case InGroup ('Domain\D9_Employee','Domain\D9_Super')
Use "L:" '\\NAS\Users\District\D9' /Persistent
Use "X:" '\\FileServer\DigitalAudio\District9' /Persistent
Use "Y:" '\\FileServer\SavedAudio\District9' /Persistent
Case InGroup ('Domain\D10_Employee','Domain\D10_Super')
Use "L:" '\\NAS\Users\District\D10' /Persistent
Use "X:" '\\FileServer\DigitalAudio\District10' /Persistent
Use "Y:" '\\FileServer\SavedAudio\District10' /Persistent
Case InGroup ('Domain\D11_Employee','Domain\D11_Super')
Use "L:" '\\NAS\Users\District\D11' /Persistent
Use "X:" '\\FileServer\DigitalAudio\District11' /Persistent
Use "Y:" '\\FileServer\SavedAudio\District11' /Persistent
Case InGroup ('Domain\D12_Employee','Domain\D12_Super')
Use "L:" '\\NAS\Users\District\D12' /Persistent
Use "X:" '\\FileServer\DigitalAudio\District12' /Persistent
Use "Y:" '\\FileServer\SavedAudio\District12' /Persistent
End Select
|
|
Top
|
|
|
|
#203280 - 2011-10-17 10:42 PM
Re: This script is too long!!!
[Re: dgraham]
|
Allen
KiX Supporter
   
Registered: 2003-04-19
Posts: 4563
Loc: USA
|
This might help with the code above, but I doubt its going to help with the speed.
untested
for $i= 1 to 12
if InGroup ('Domain\D' + $i + '_Employee','Domain\D' + $i + '_Super')
Use "L:" '\\NAS\Users\District\D' + $i
Use "X:" '\\FileServer\DigitalAudio\District' + $i
Use "Y:" '\\FileServer\SavedAudio\District' + $i
endif
next
Edited by Allen (2011-10-18 12:58 AM)
|
|
Top
|
|
|
|
#203282 - 2011-10-17 10:47 PM
Re: This script is too long!!!
[Re: ShaneEP]
|
ShaneEP
MM club member
   
Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
|
Allen already beat me to it, code wise, but here is another option for fun...
Select
;Districts
Case InGroup ('Domain\D1_Employee','Domain\D1_Super')
$district = 1
Case InGroup ('Domain\D2_Employee','Domain\D2_Super')
$district = 2
Case InGroup ('Domain\D3_Employee','Domain\D3_Super')
$district = 3
Case InGroup ('Domain\D4_Employee','Domain\D4_Super')
$district = 4
Case InGroup ('Domain\D5_Employee','Domain\D5_Super')
$district = 5
Case InGroup ('Domain\D6_Employee','Domain\D6_Super')
$district = 6
Case InGroup ('Domain\D7_Employee','Domain\D7_Super')
$district = 7
Case InGroup ('Domain\D8_Employee','Domain\D8_Super')
$district = 8
Case InGroup ('Domain\D9_Employee','Domain\D9_Super')
$district = 9
Case InGroup ('Domain\D10_Employee','Domain\D10_Super')
$district = 10
Case InGroup ('Domain\D11_Employee','Domain\D11_Super')
$district = 11
Case InGroup ('Domain\D12_Employee','Domain\D12_Super')
$district = 12
EndSelect
Use L: '\\NAS\Users\District\D'+$district /Persistent
Use X: '\\FileServer\DigitalAudio\District'+$district /Persistent
Use Y: '\\FileServer\SavedAudio\District'+$district /Persistent
Edited by ShaneEP (2011-10-17 10:47 PM)
|
|
Top
|
|
|
|
#203283 - 2011-10-17 11:07 PM
Re: This script is too long!!!
[Re: dgraham]
|
cjutting
Fresh Scripter
Registered: 2010-02-05
Posts: 40
Loc: IA
|
I'm assuming you have Active Directory sites and services setup properly.
You could also do
if @site = "District_1"
Use "L:" '\\NAS\Users\District\D1' /Persistent
Use "X:" '\\FileServer\DigitalAudio\District1' /Persistent
Use "Y:" '\\FileServer\SavedAudio\District1' /Persistent
endif
You could also do other stuff within the @site if needed. We have some specific site related items that are done at logon.. takes care of it pretty easy
Edited by cjutting (2011-10-17 11:09 PM)
|
|
Top
|
|
|
|
#203284 - 2011-10-18 12:48 AM
Re: This script is too long!!!
[Re: Allen]
|
dgraham
Fresh Scripter
Registered: 2006-04-11
Posts: 39
Loc: Santa Fe, New Mexico
|
Wow! Thanks Allen. That's awesome! Nice and clean. I kept thinking a Select statement would run faster than a loop because it would exit once it found a true condition, but of course the group membership is cached. I didn't think of that. Duh :-)
I guess I just assumed that part of the slowness was because the script had so many lines to parse, but now that you all point it out, that probably isn't the case. There are a lot of drive mappings. (Wouldn't it be great if end users could learn how to navigate a directory instead of asking for drive mappings to every single shared folder) Perhaps it just takes a while for Windows to map drives across a slow network link. The script can sometimes take up to a minute to complete.
|
|
Top
|
|
|
|
#203285 - 2011-10-18 12:51 AM
Re: This script is too long!!!
[Re: cjutting]
|
dgraham
Fresh Scripter
Registered: 2006-04-11
Posts: 39
Loc: Santa Fe, New Mexico
|
Thanks cjutting. I have considered Sites and Services. But I have never set it up. I'm told it only works reliably with a domain controller at each site. I have over 60 locations, and most of them are small (5-30 workstations) so I have never been able to convince the guys with the money that it's worth it to put a server at each site. Does this hold with your experience?
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 235 anonymous users online.
|
|
|