Re: Logon script - function array and select case not working
- From: "Al Dunbar" <alandrub@xxxxxxxxxxx>
- Date: Tue, 9 Jun 2009 22:08:18 -0600
I received a copy of your post below as a personal e-mail. When I replied to ask that you keep the discussion in the group because it serves no purpose to have a private discussion, my e-mail to you bounced because the email address you supplied was not valid.
Please stop this practice.
/Al
"Nex6" <Nex6@xxxxxxxxxxxxxxx> wrote in message news:alpine.WNT.2.00.0906091721360.8168@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
This, is really the first time I tryed to mess with arrays and select case, I do a fair amount of scripting but nothing with case and arrays. i used a dicionary object but that was it.
On Tue, 9 Jun 2009, Al Dunbar wrote:
"Nex6" <Nex6@xxxxxxxxxxxxxxx> wrote in message news:alpine.WNT.2.00.0906091532310.6772@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxHi all,
I am trying to rewrite my logon scripts which are all in vbscript. the scripts are written in a framework model, eg: control script,hashtable script and subscripts which are for each group.
the hash table, has all the names, and server paths, and all the scripts use those names from the central hash table (via an include function) (this is so if server name changes i just change the path in the hash table)
this all works well, except, the function i am using for the rules in the control script causes alot of querrys to AD. as there are alot of groups.
In my experience, testing group membership is expensive, no matter how you try to do it.
so my thinking was have a function dump all the groups into an array,
How have you determined that this will be faster or result in fewer trips to the domain?
becuase the current product script, is based like so:
if ismember "groupname" then
obj.run "\\ad\sysvol\~\subscriptdept.vbs
end if
only alot of them... like about 50 or 60, so every querry is a call to AD. thats too much, i want/need to cut that down.
pass the array to a select case and fire off the subscripts inside the case statement. (there are more the 60 groups is there a limit to case?
I am unaware of any limit to the number of cases in a select case block...
here is what i have:
/code
dim dataarray()
dim data
dim retrv
dim obj
set objFSO = CreateObject("Scripting.FileSystemObject")
set objTSout = objFSO.CreateTextFile(".\loglinfunction.txt", true)
set objTSout2 = objFSO.CreateTextFile(".\logoutfunction.txt", true)
set objTSout3 = objFSO.CreateTextFile(".\top.txt", true)
set objTSout4 = objFSO.CreateTextFile(".\logarrayfunction.txt", true)
objTSout.writeline retrv
what value are you expecting this statement to write into the file, given that retrv has yet to be assigned a value?
this is debug stuff, so I can see the vaules at that point in the script, infact all the writelines are just for debugging to help me see output.
retrv = checkgrp
what value are you expecting this will assign to retrv?
here is am trying to get the array into something i can use in the select case. I have been playing with it alot, so some things may be messy :)
'for each obj in retrv
Select Case retrv
Case "group name here" wscript.echo "ok"
Case "green" document.bgColor = "green"
Case "blue" document.bgColor = "blue"
'Case Else MsgBox "pick another color"
End Select
The above will do one of three actions depending on the value of retrv being either "group name here", "green", or "blue". If retrv is anything else, nothing will happen.
yup, nothing happens, which i know becuase i am outputing everything at each stage to files for me to look at.
When you run this, what happens? I expect nothing as noted in my comment just after the end function statement...
nothing, becuase the arrays data never leaves the for loop in the function.
hunh?
Also, where is the document object defined?
'next
private function checkgrp()
'dim dataarray()
'dim data
On Error Resume Next
Set objADSysInfo = CreateObject("ADSystemInfo")
strUser = objADSysInfo.UserName
Set objUser = GetObject("LDAP://" & strUser)
For Each strGroup in objUser.memberOf
Set objGroup = GetObject("LDAP://" & strGroup)
'Wscript.Echo objGroup.CN
redim Preserve dataarray(data)
where does "data" get its value from?
below, i am trying to have a dynamic array, becuase this is polling group member ship and everyone will be different.
dataarray(data) = objGroup.CN
retrv = dataarray(data)
Assigning a value from within a function to a global variable is not a good idea.
i know, i was trying diffeent things to get it to work, notice the commented out at the top of the function.
'wscript.echo dataarray(data)
'objTSout.writeline dataarray(data)
'objTSout.writeline checkgrp
Next
'objTSout2.writeline dataarray()
objTSout2.writeline retrv
objTSout4.writeline dataarray(data)
'wscript.echo strname
end function
Since no value has been assigned to the name of the function, the value returned has nothing to do with anything the function has done.
i tryed doing things like checkgrp = arrayname, but it still does not work. so i , after google and nothing, basicly am trying everything I can think of. but since i never really played with arrays that much, and passing data from an array in a function seems to be a black art in vbscript....
wscript.echo "script has finished running"
/end code
Neither the intent nor the execution of the code is clear to me. Since it contains numerous errors, I am wondering why you think it is the function and select case statements themselves that are responsible rather than your code.
object, in the function get the array populted with the user who runs it, with all the groups. then, the select case, would be formated like so:
select case
case script_department.vbs
end case
only like 60 cases. then those subscript, are the real login scripts for the users. and, those subscripts, i have an inlcude function the pulls a hashtable with everything they need to map all the drivers etc.
hope this clears it up some.
/Al
.
- References:
- Prev by Date: Re: best way to get xml value
- Next by Date: Re: Zip error using VBSCRIPT Error:Object not a collection
- Previous by thread: Re: Logon script - function array and select case not working
- Next by thread: Re: Logon script - function array and select case not working
- Index(es):
Relevant Pages
|