#200549 - 2010-11-09 10:41 PM
Re: problem reading af file for use in script
[Re: Glenn Barnas]
|
Shanee
Fresh Scripter
Registered: 2006-10-13
Posts: 39
Loc: Tulsa, OK
|
I agree. This eliminates the need to edit the script to add further groups.
$mac = GetBSSID(1,@WkSta)
$location = ReadProfileString ($LogonServer+"\NETLOGON\printer.ini", $mac, "Location")
$groups = ReadProfileString ($LogonServer+"\NETLOGON\printer.ini", $mac, "Groups")
$groups = Split($groups,",")
For Each $group in $groups
If InGroup($group)
$shares = ReadProfileString ($LogonServer+"\NETLOGON\printer.ini", $mac+":"+$group, "Shares")
$shares = Split($shares,",")
$sharenum = 0
For Each $shareobj in $shares
$name = Split($shareobj,":")[0]
$share = Split($shareobj,":")[1]
If AddPrinterConnection("\\server\"+$share) = 0
If $sharenum = UBound($shares)
$null = SetDefaultPrinter("\\server\"+$name)
EndIf
Else
$null = MessageBox("2 Der er et problem med at etablerer forbindelse til : "+$share,"Printer fejl",0)
EndIf
$sharenum = $sharenum+1
Next
EndIf
Next
[00:25:9C:AD:43:D6]
Location = Preparation
Groups = Student,Teacher,Admin
[00:25:9C:AD:43:D6:Teacher]
Shares = HP LaserJet 1320nw - Support:LaserJet1,Xerox WorkCentre 7345:Xerox1
[00:25:9C:AD:43:D6:Student]
Shares = HP LaserJet 1320nw - Support:LaserJet1
[00:25:9C:AD:43:D6:Admin]
Shares = HP LaserJet 1320nw - Support:LaserJet1,Xerox WorkCentre 7345:Xerox1,Other Admin Printer:Admin1
|
Top
|
|
|
|
#200622 - 2010-11-15 09:23 PM
Re: problem reading af file for use in script
[Re: Glenn Barnas]
|
roundup
Fresh Scripter
Registered: 2010-10-29
Posts: 11
Loc: Denmark
|
Hi Glenn
Can you show me how the finale kix-code will look like, with the use of you $Tag code please!?
Kind regards roundup
|
Top
|
|
|
|
#200623 - 2010-11-15 10:58 PM
Re: problem reading af file for use in script
[Re: roundup]
|
Shanee
Fresh Scripter
Registered: 2006-10-13
Posts: 39
Loc: Tulsa, OK
|
Sample .ini format
[00:25:9C:AD:43:D6]
Location = Preparation
Groups = Teacher,Student,Admin
[00:25:9C:AD:43:D6:Teacher]
Shares = HP LaserJet 1320nw - Support:LaserJet1,Xerox WorkCentre 7345:Xerox1
[00:25:9C:AD:43:D6:Student]
Shares = HP LaserJet 1320nw - Support:LaserJet1
[00:25:9C:AD:43:D6:Admin]
Shares = HP LaserJet 1320nw - Support:LaserJet1,Xerox WorkCentre 7345:Xerox1,Other Admin Printer:Admin1
Kix script
$mac = GetBSSID(1,@WkSta)
$location = ReadProfileString ($LogonServer+"\NETLOGON\printer.ini", $mac, "Location")
$groups = ReadProfileString ($LogonServer+"\NETLOGON\printer.ini", $mac, "Groups")
$groups = Split($groups,",")
$Tag = 1
For Each $group in $groups
If InGroup($group) and $Tag
$Tag = 0
$shares = ReadProfileString ($LogonServer+"\NETLOGON\printer.ini", $mac+":"+$group, "Shares")
$shares = Split($shares,",")
$sharenum = 0
For Each $shareobj in $shares
$name = Split($shareobj,":")[0]
$share = Split($shareobj,":")[1]
If AddPrinterConnection("\\server\"+$share) = 0
If $sharenum = UBound($shares)
$null = SetDefaultPrinter("\\server\"+$name)
EndIf
Else
$null = MessageBox("2 Der er et problem med at etablerer forbindelse til : "+$share,"Printer fejl",0)
EndIf
$sharenum = $sharenum+1
Next
EndIf
Next
FUNCTION GetBSSID(optional $device, optional $machine)
$strComputer = IIF (VarType($machine)<2, @Wksta, $Machine)
$objSWbemServices = GetObject("winmgmts:\\"+ $strComputer + "\root\wmi")
$colInstances = $objSwbemServices.ExecQuery("SELECT * FROM MSNdis_80211_ReceivedSignalStrength WHERE Active=True")
if $device<1
$card_no=1
$cards = "Please specify one of these devices to obtain it's BSSID :"
for each $objInstance in $colInstances
$cards = $cards+@CRLF+"Card "+$card_no+" = "+$objInstance.InstanceName
$card_no=$card_no +1
next
$GetBSSID = $cards
Return
endIf
$card_no=$device
$x=1
for each $objInstance in $colInstances
if $x = $card_no
$wifiAdapter = $objInstance.InstanceName
$x = $x + 1
endif
next
$last_signal = 0
$bssid = ""
$colInstances = $objSwbemServices.ExecQuery('SELECT * FROM MSNdis_80211_BaseServiceSetIdentifier WHERE Active = True AND InstanceName ="'+$wifiAdapter+'"')
for each $objInstance in $colInstances
$macbyte = 0
for each $decval in $objInstance.Ndis80211MacAddress
if $decval<17
$bssid = $bssid + "0"
endif
$bssid = $bssid + DecToHex($decval)
if $macbyte < 5
$bssid = $bssid + ":"
$macbyte = $macbyte + 1
endif
next
next
$colInstances = $objSwbemServices.ExecQuery ("SELECT * FROM MSNdis_80211_ReceivedSignalStrength WHERE Active = True AND InstanceName ='" + $wifiAdapter + "'")
for each $objInstance in $colInstances
$sigraw = $objInstance.Ndis80211ReceivedSignalStrength
$signal = $sigraw + "dB"
next
$last_signal = $sigraw
$GetBSSID = $bssid
ENDFUNCTION
|
Top
|
|
|
|
#200640 - 2010-11-17 08:24 PM
Re: problem reading af file for use in script
[Re: Lonkero]
|
Shanee
Fresh Scripter
Registered: 2006-10-13
Posts: 39
Loc: Tulsa, OK
|
HaHa, Yeah I know. But I'm usually bored at work anyways. Just now started messing about with Kix again.
|
Top
|
|
|
|
#200666 - 2010-11-20 08:01 PM
Re: problem reading af file for use in script
[Re: Mart]
|
Shanee
Fresh Scripter
Registered: 2006-10-13
Posts: 39
Loc: Tulsa, OK
|
Haha, well I used to be in the IT field so I know the kind of workload you're referring to. But now I work in an optical lab making lenses for glasses. Just a random job as I work towards my electrical engineering degree. Sometimes it's busy and sometimes not so much.
btw...this was me back in the day.. http://www.kixtart.org/forums/ubbthreads.php?ubb=showprofile&User=2761
|
Top
|
|
|
|
#200668 - 2010-11-20 08:53 PM
Re: problem reading af file for use in script
[Re: Allen]
|
Shanee
Fresh Scripter
Registered: 2006-10-13
Posts: 39
Loc: Tulsa, OK
|
Didn't have the same email account anymore, and to be honest I couldn't even remember what it was until I re-registered and went thru the user list for possible id's lol. Maybe I'll try to get it working again now that I know what it is.
|
Top
|
|
|
|
#200669 - 2010-11-20 08:59 PM
Re: problem reading af file for use in script
[Re: Shanee]
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4545
Loc: USA
|
I'm sure Rich or Jooel can help you out with that.
My account name back then was likely Alpo. There was a post just a few months back talking about how long people had been trolling around here... and when I say "6 years" since you were here... it's just mind boggling that I have been here that long (and longer).
|
Top
|
|
|
|
#200745 - 2010-11-24 12:43 PM
Re: problem reading af file for use in script
[Re: ShaneEP]
|
roundup
Fresh Scripter
Registered: 2010-10-29
Posts: 11
Loc: Denmark
|
Hi Shane
Thanks, again I thank you for your good feedback and excellent support.
Bedst regards roundup
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 248 anonymous users online.
|
|
|