#105702 - 2003-10-10 05:49 AM
Re: Primary computer group membership
|
tjcarst
Hey THIS is FUN
Registered: 2003-09-08
Posts: 243
Loc: USA
|
Thanks, I'll read the info.
I had not refreshed my screen before posting the previous reply. Sorry.
Terri
|
Top
|
|
|
|
#105703 - 2003-10-10 06:01 AM
Re: Primary computer group membership
|
tjcarst
Hey THIS is FUN
Registered: 2003-09-08
Posts: 243
Loc: USA
|
Whew! I finally noticed the looked over link you sent. I am going to call it quits, it's been a long day. The RID/SID mapping looks like a project for tomorrow or even this weekend.
I may try your Win32Admin.dll and see what I can come up with.
Thanks, Howard.
Terri
|
Top
|
|
|
|
#105704 - 2003-10-10 08:38 PM
Re: Primary computer group membership
|
tjcarst
Hey THIS is FUN
Registered: 2003-09-08
Posts: 243
Loc: USA
|
Okay, this may be extra work creating groups, but it may be the easiest way to set the primary printer when there are multiple printers installed.
Create a group specifically for a default printer group. Like DefPrinter_MRH-01_Q-MIS2 and put pcs in this group to get default/only printer of Q-MIS2. Create another group Printer_MRH-01_Q-MIS2 for users that have this additional printer. Use the SetDefaultPrinter in the script to set default printer if group name starts with DefPrinter.
tjcarst
|
Top
|
|
|
|
#105705 - 2003-10-10 08:47 PM
Re: Primary computer group membership
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Either way requires some additional effort.
The default group I think was suggested previously and will enable others to more easily make changes. However, groups are not mutually exclusive so someone could place a computer into mopre than one default printer group. This would cause potentially some confusion and may be difficult to track down. This approach needs to have a group management methodology in place to find duplicate entires in your default printer groups.
Using the PrimaryGroupID would eliminate this issue since it can only hold one value. You will have to add code to convert the RID of the group to the name. As mentioned in the other thread you could use some of the approaches listed there.
|
Top
|
|
|
|
#105706 - 2003-10-10 11:41 PM
Re: Primary computer group membership
|
tjcarst
Hey THIS is FUN
Registered: 2003-09-08
Posts: 243
Loc: USA
|
Thanks, Howard.
I am not a programmer, getting to this point has been a long process. The printers are needed ASAP as we are moving away from shared signons in our hospital for HIPAA. There are hundreds of nurses and therapists that will have no printer when they signon.
I am not too worried about a computer being in two default printer groups. I am the only one that maintains AD now, so would know to check the group membership. It may take me 10 minutes to remember, but I'm pretty good at this. The majority of pc's don't have multiple printers, so there are maybe 20% that would be in the other group.
I don't think I can get the RID/SID to work by next week, but I'll work on it this weekend.
Your assistance has been appreciated.
tjcarst [ 10. October 2003, 23:41: Message edited by: tjcarst ]
|
Top
|
|
|
|
#105707 - 2003-10-12 10:49 PM
Re: Primary computer group membership
|
tjcarst
Hey THIS is FUN
Registered: 2003-09-08
Posts: 243
Loc: USA
|
To check if the computer is in more than one default printer group, I'd like to count for the existence of more than one group starting with the string "DefPrinter_ " and send a message to an administrator and exit, not changing the current default printer.
I can't get this script to work. Putting my computer in two DefPrinter_ groups does not send a message and continues to set both as default, with the last one the default.
code:
;http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=1;t=007920
call @ScriptDir+'\PriMapState.udf'
;********** Prevent script from running on a server or Win95********* if @userid = administrator call @Scriptdir+'\osid.udf' $os=osid() if $os[1]='Win95' or $os[2]<>'Workstation' exit 0 endif endif
;********** Prevent script from running on Medrec pcs ********* if InGroup ("Medrec Group") exit 0 endif
;********** Beginning of printer mapping *********
$WS = GetObject("WinNT://" + @domain + "/" + @wksta + "$$") if @error ? @serror else for each $grp In $WS.Groups $GrpName = $grp.Name
;--- Add and set default printer ---
if left($GrpName,11) = "DefPrinter_" $defprinter = substr($GrpName,12) $defprinter = join(split($defprinter,"_"),"\")
if count(left(GrpName,11) = "DefPrinter_") > 1 ? "Computer already has default printer" ? "Check Computer is only in one DefPrinter group" ? "Printer not added!" $rc=SendMessage(testpc, '@wksta is in more than one DefPrinter Group, please set to only one!!') exit 0
else if not PriMapState("\\" + $defprinter) ? "Status - Printer not connected \\"+$defprinter $S=AddPrinterConnection("\\" + $defprinter) ? "Status - Printer added \\"+$defprinter ? @serror ? $S=SetDefaultPrinter ("\\" + $defprinter) ? "Status - Default Printer set \\"+$defprinter ? @serror endif
if PriMapState("\\" + $defprinter)<>2 $S=SetDefaultPrinter ("\\" + $defprinter) ? "Status - Default Printer set \\"+$defprinter ? @serror endif
endif
endif
;--- Add secondary printers --- if left($GrpName,8) = "Printer_" $printer = substr($GrpName,9) $printer = join(split($printer,"_"),"\")
if not PriMapState("\\" + $printer) ? "Status - Printer not connected \\"+$printer $S=AddPrinterConnection("\\" + $printer) ? "Status - Printer added \\"+$printer ? @serror ? endif
endif next
endif
edited to reflect $printer should be $defprinter in Default printer portion of script. Removed $ from in front of $count. [ 13. October 2003, 04:44: Message edited by: tjcarst ]
|
Top
|
|
|
|
#105709 - 2003-10-13 04:32 AM
Re: Primary computer group membership
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
What is this?
$count(left(GrpName,11) = "DefPrinter_")
|
Top
|
|
|
|
#105710 - 2003-10-13 04:38 AM
Re: Primary computer group membership
|
tjcarst
Hey THIS is FUN
Registered: 2003-09-08
Posts: 243
Loc: USA
|
Well, it was my attempt to determine if the computer was in more than one Default Printer Group. If count was more than 2, send a message and not add second default printer.
|
Top
|
|
|
|
#105712 - 2003-10-13 04:48 AM
Re: Primary computer group membership
|
tjcarst
Hey THIS is FUN
Registered: 2003-09-08
Posts: 243
Loc: USA
|
Drat! I thought I could use it to determine if the computer was in more than one group starting with "DefPrinter_" and then send a message to myself and not change the current default printer.
I saw count used by others in scripts, I'll have to see how it was used and post an example. [ 13. October 2003, 04:56: Message edited by: tjcarst ]
|
Top
|
|
|
|
#105713 - 2003-10-13 05:20 AM
Re: Primary computer group membership
|
tjcarst
Hey THIS is FUN
Registered: 2003-09-08
Posts: 243
Loc: USA
|
Count wasn't anything, I guess. I wanted to see if the computer was in multiple groups. Sum?? I am searching for a way to only allow one group starting with a specific string, but don't know all of the correct kixtart udf's or commands, obviously. I did not create a variable, as I did not know how to use it in my context. I mistakenly thought I could use it to count the existence of the data within the following if count().
Is there a way to use ComputerIngroup.udf to enumerate the list of groups of which a computer is a member and if the list includes more than one group starting with "DefPrinter" exiting and sending a message? [ 13. October 2003, 05:22: Message edited by: tjcarst ]
|
Top
|
|
|
|
#105714 - 2003-10-13 06:12 AM
Re: Primary computer group membership
|
NTDOC
Administrator
Registered: 2000-07-28
Posts: 11624
Loc: CA
|
Yes there is. IF/SELECT-CASE maybe based on INSTR or other.
For a full list of UDFs and easier searching please visit this site and review the UDF section.
KiXhelp.com
I also have a .CHM help file for download on the site that has All the UDFs and many other items of interest included. [ 13. October 2003, 06:13: Message edited by: NTDOC ]
|
Top
|
|
|
|
#105716 - 2003-10-13 04:25 PM
Re: Primary computer group membership
|
tjcarst
Hey THIS is FUN
Registered: 2003-09-08
Posts: 243
Loc: USA
|
Thanks.
I have visited the UDF site and have searched this site extensively. Thus far, I haven't found anything that works for my environment.
Modifying the schema isn't something that I would like to try, either
I can't figure out the INI file, so I was trying it with groups. sealeopard also mentioned an INI file, and wanted to know specifically what I was trying to do. Noting that my INI file wasn't optimized. Not knowing how to optimize it, I am stuck.
Now that I have captured existing printers, I would like to use the INI file exclusively to control the managment of printers. Adding and removing printers using this INI file only, not Windows. When users login, the INI file is checked based upon the computername, and printers are added and removed using the existing INI file.
I have considered modifying the existing script to only READPROFILESTRING and not WRITEPROFILESTRING, but can't figure out the logic on my own. Again, my lack of programming skills are apparent.
If anyone can make suggestions to my existing scripts, it would be wonderful. I now know using group membership isn't the best way, so I'd like to try and figure out the INI file, with assistance.
I have an existing INI file for over 400 pc's. It is created by this code:
code:
;Re-Write at http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=2;t=004308 ;By Kdyer & Lonkero (15th april 2003) ;Re-Write of http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=10;t=000021 ; Ref. http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=1&t=006790 ; Ref. http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=12;t=000221
;********** Prevent logon script on server *********
call @ScriptDir+'\osid.udf'
$os=osid() if $os[2]<>'Workstation' exit 0 endif
;********** Prevent script from running on Medrec pcs *********
if InGroup ("Medrec Group") exit 0 endif
;********** Beginning of printer configuration script *********
;---- Default Printer Configuration ----
;This is to capture the Default Printer and get all network defined printers as well $loc='HKEY_CURRENT_USER\Network\LPT1' $reg='HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion' $dev=$reg+'\Devices' $nprt=split(READVALUE($reg+'\Windows','Device'),',')[0] $sysdrv=SUBSTR('%WINDIR%',1,2) dim $priReg, $x, $i, $rc, $ps ; ---- Set Printsetup.ini file location ----
$ps=('\\mrh-01\prtlog$') $ps=($ps+'\@wksta')
IF 0=EXIST($ps) MD $ps ENDIF
$ps=$ps+'\Printsetup.ini' $i=0 DO IF '\\'=LEFT($x,2) $priReg=$priReg+$x ENDIF $x=ENUMVALUE($dev,$i) $i=$i+1 UNTIL @error IF LEN($priReg) $rc=WRITEPROFILESTRING($ps,'Printers','','') $priReg=split($priReg,'\\') FOR $i=1 to ubound($priReg) $rc=WRITEPROFILESTRING($ps,'Printers',$i,'\\'+$priReg[$i]) NEXT ENDIF SELECT CASE INSTR($nprt,'\\') ;WRITE THE DEFAULT PRINTER TO THE CONFIG $rc=WRITEPROFILESTRING($ps,'Printers','Default',$nprt) USE LPT1: /delete /persistent USE LPT1: $nprt /persistent CASE $nprt='' AND EXIST($ps) ;NO DEFAULT PRINTER, LOAD PRINTERS FROM SAVED INFO FOR EACH $key IN split(readprofilestring($ps,'Printers',''),chr(10)) $nul=addprinterconnection(readprofilestring($ps,'Printers',$key)) NEXT $nprt=READPROFILESTRING($ps,'Printers','Default') $rc=SETDEFAULTPRINTER($nprt) USE LPT1: $nprt /persistent CASE NOT INSTR($nprt,'\\') ;LOCAL PRINTER DEFAULT, SO WE WANT TO REMOVE NETWORK MAPPING USE LPT1: /delete /persistent ENDSELECT
Resulting INI file: [Printers] 1=\\mrh-01\q-mis1 2=\\mrh-01\q-mis2 Default=\\mrh-01\q-mis2
This works to add printers if all are deleted, however, if I delete one, it just updates the INI file. I want it to add it back by checking the INI file. Currently, it updates the computer using the INI file with the previously recorded printers ONLY if there are none.
How do I modify this script to use the INI file EXCLUSIVELY for printer management?
Thanks.
tjcarst [ 13. October 2003, 16:31: Message edited by: tjcarst ]
|
Top
|
|
|
|
#105717 - 2003-10-13 04:56 PM
Re: Primary computer group membership
|
tjcarst
Hey THIS is FUN
Registered: 2003-09-08
Posts: 243
Loc: USA
|
Okay, I've modified the script so that it will add printers based upon the INI file, how do I make it delete printers from computers when they do not exist in the INI file?
code:
;********** Prevent logon script on server ********* call @ScriptDir+'\osid.udf'
$os=osid() if $os[2]<>'Workstation' exit 0 endif
;********** Beginning of printer info gathering script *********
;Default Printer Configuration ;This is to capture the Default Printer and get all network defined printers as well $loc='HKEY_CURRENT_USER\Network\LPT1' $reg='HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion' $dev=$reg+'\Devices' $nprt=split(READVALUE($reg+'\Windows','Device'),',')[0] $sysdrv=SUBSTR('%WINDIR%',1,2) dim $priReg, $x, $i, $rc, $ps ;---- Set Printsetup.ini file location ---- $ps=('\\mrh-01\prtlog$') $ps=($ps+'\@wksta') IF 0=EXIST($ps) MD $ps ENDIF
$ps=$ps+'\Printsetup.ini' $i=0 DO IF '\\'=LEFT($x,2) $priReg=$priReg+$x ENDIF $x=ENUMVALUE($dev,$i) $i=$i+1 UNTIL @error SELECT CASE EXIST($ps) ;PRINTERS FROM SAVED INFO FOR EACH $key IN split(READPROFILESTRING($ps,'Printers',''),chr(10)) $nul=addprinterconnection(READPROFILESTRING($ps,'Printers',$key)) NEXT $nprt=READPROFILESTRING($ps,'Printers','Default') $rc=SETDEFAULTPRINTER($nprt) USE LPT1: $nprt /persistent
CASE NOT INSTR($nprt,'\\') ;LOCAL PRINTER DEFAULT, SO WE WANT TO REMOVE NETWORK MAPPING USE LPT1: /delete /persistent ENDSELECT
|
Top
|
|
|
|
#105718 - 2003-10-13 06:14 PM
Re: Primary computer group membership
|
Kdyer
KiX Supporter
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Looks like you are using the Default Printer Script from the FAQ Forum.
The way it functions is as follows: (1) Check to see if there are printers installed (2) If there are no printers, it checks for the INI file and if found, reads them in (3) Write out the INI file to shared drive
HTH,
Kent
|
Top
|
|
|
|
#105719 - 2003-10-13 06:33 PM
Re: Primary computer group membership
|
tjcarst
Hey THIS is FUN
Registered: 2003-09-08
Posts: 243
Loc: USA
|
Yes. But it isn't working as I would like.
|
Top
|
|
|
|
#105721 - 2003-10-13 09:13 PM
Re: Primary computer group membership
|
tjcarst
Hey THIS is FUN
Registered: 2003-09-08
Posts: 243
Loc: USA
|
Thanks, sealeopard. I have looked at that function and several mapprinter functions.
My problem is that I need to use variables and I have a hard time writing the logic that searches for the group membership and determines the printer and print server for each and then either maps or unmaps the printers based upon either the ini file or group membership.
For the most part, I can get group membership or an ini file to work, but there are a few things I haven't figured out how to do. Only one of the methods should be used. For either, there are problems as pointed out in this thread.
1. if using groups, make sure user is only in one group that assigns default printers
2. if using an ini file for each computer, have the ini file duplicate the printer setup in the file on the computer (not user based). If printer not in INI file, delete. If in file, but not on pc, install. [ 13. October 2003, 21:15: Message edited by: tjcarst ]
|
Top
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 421 anonymous users online.
|
|
|