Page 1 of 1 1
Topic Options
#203279 - 2011-10-17 09:37 PM This script is too long!!!
dgraham Offline
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!


 Code:
 
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 Administrator Online   shocked
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
 Code:
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
#203281 - 2011-10-17 10:44 PM Re: This script is too long!!! [Re: dgraham]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
You might be able to shorten it code wise using some kind of loop, but in my opinion I don't see anything that should be slowing down your clients.

Considering that the first CASE that it hits will be the one used (the rest will be skipped), and that group memberships are typically cached, it should be fine.

Top
#203282 - 2011-10-17 10:47 PM Re: This script is too long!!! [Re: ShaneEP]
ShaneEP Moderator Offline
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...

 Code:
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 Offline
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

 Code:
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 Offline
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 Offline
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
#203286 - 2011-10-18 01:03 AM Re: This script is too long!!! [Re: dgraham]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4563
Loc: USA
I suggest taking your script and cutting it into chunks. Then you might be able to see where the lag is.

By the way, if you use the script above, I modified it, as I saw some glaring bugs in it, and also removed the persistence. I rarely ever see a reason to use it, because when you log in, they get mapped anyway.

Top
#203288 - 2011-10-18 04:23 PM Re: This script is too long!!! [Re: dgraham]
cjutting Offline
Fresh Scripter

Registered: 2010-02-05
Posts: 40
Loc: IA
I see what you mean having a DC at each site. We do have DCs at each site so it works out ok. Don't know what your final plans or goals are, but you could test it to see if it functions without having a DC at each site. Something to toss around for the idea board
Top
#203299 - 2011-10-20 10:56 PM Re: This script is too long!!! [Re: cjutting]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
I don't trust the @SITE myself.

I see way too many errors and machines that seem to lose or not know what site they belong to. Good idea by Microsoft but needs to be more resilient

Top
Page 1 of 1 1


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

Who's Online
0 registered and 235 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.075 seconds in which 0.037 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