tjcarst
(Hey THIS is FUN)
2011-12-14 08:15 PM
Printer mapping script not working in Windows 7

Has worked flawlessly on 2000 and XP. It does not run on Windows 7.

 Code:
;********** Beginning of printer mapping *********
call @ScriptDir+'\PriMapState.udf'

$WS = GetObject('WinNT://' + @domain + '/' + @wksta + '$$')
 
if @error
   ? @serror
else

$ps1='prn01'
$ps2='prn02'
$ps3='prn03'
$ps4='prn04'
$ps5='prn05'


   for each $grp In $WS.Groups
      $GrpName = $grp.Name


;--- Add additional printers ---

     if left($GrpName,2) = 'A0' ;

	$psn = substr($Grpname,2,2)  ;print server number determined by 2-3 characters A01=PS1

	if $psn='01' $ps=$ps1 endif
	if $psn='02' $ps=$ps2 endif
	if $psn='03' $ps=$ps3 endif
	if $psn='04' $ps=$ps4 endif
	if $psn='05' $ps=$ps5 endif

	$addlprinter = substr($GrpName,5)  ;printer group name starts at 5th character Ex. Group D01_q-mis or A01_q-mis

	$addlprinter = $ps+'\'+$addlprinter
        $addlprinter = '\\'+$addlprinter
        ? "Additional Printer: "$addlprinter

         if not PriMapState($addlprinter)
	    ? "Status: Printer not connected " + $addlprinter
	    $nul=AddPrinterConnection($addlprinter)
	    ? "Status: Printer added " + $addlprinter
	    ? @serror
         endif
     endif 

;--- Add and set default printer ---

      if left($GrpName,2) = 'D0'  ;print server number determined by third character D01=PS1 D02=PS2

	$defprinter = substr($GrpName,5) ;printer group name starts at 5th character
	$psn = substr($Grpname,2,2)

	if $psn='01' $ps=$ps1 endif
	if $psn='02' $ps=$ps2 endif
	if $psn='03' $ps=$ps3 endif
	if $psn='04' $ps=$ps4 endif
	if $psn='05' $ps=$ps5 endif

        $defprinter = $ps+'\'+$defprinter
        $defprinter = '\\'+$defprinter
         ? "** Printers assigned through Printer Setup Group **"
         ? " "
         ? "Default Printer:    "$defprinter

         if not PriMapState($defprinter)
            ? "Status: Printer not connected "+$defprinter
            $nul=AddPrinterConnection($defprinter)
            ? "Status: Printer added "+ $defprinter
            ? @serror
 	    $nul=SetDefaultPrinter($defprinter)
            ? "Status: Default Printer set "+ $defprinter
            ? @serror
         endif
  
         if PriMapState($defprinter)<>2
            $nul=SetDefaultPrinter($defprinter)
             ? "Status: Default Printer changed "+ $defprinter
             ? @serror
         endif
      endif
   next
endif



AllenAdministrator
(KiX Supporter)
2011-12-14 09:18 PM
Re: Printer mapping script not working in Windows 7

If this is a GPO Startup Script... see the following thread for ideas.

http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=198514#Post198514

If not, post back.


tjcarst
(Hey THIS is FUN)
2011-12-14 09:29 PM
Re: Printer mapping script not working in Windows 7

This is not a gpo startup script. I call it from kix.bat on the user profile settings tab.

Thanks!


tjcarst
(Hey THIS is FUN)
2011-12-14 09:30 PM
Re: Printer mapping script not working in Windows 7

Forgot to mention, that I am testing it by manually running it from a command prompt. Works fine on XP, just not Windows 7. Drives are mapped, but printers based upon ComputerInGroup are not mapped.

AllenAdministrator
(KiX Supporter)
2011-12-14 09:47 PM
Re: Printer mapping script not working in Windows 7

Are the Win7 pcs 64bit? If so, you have to have the 64bit drivers installed on the server as well.

AllenAdministrator
(KiX Supporter)
2011-12-14 10:03 PM
Re: Printer mapping script not working in Windows 7

Also, what is the @serror returned after the addprinterconnection() line.

tjcarst
(Hey THIS is FUN)
2011-12-14 11:52 PM
Re: Printer mapping script not working in Windows 7

No error gets returned.

tjcarst
(Hey THIS is FUN)
2011-12-14 11:52 PM
Re: Printer mapping script not working in Windows 7

Yes, 64-bit Windows 7.

tjcarst
(Hey THIS is FUN)
2011-12-14 11:53 PM
Re: Printer mapping script not working in Windows 7

64-bit kix drivers? Separate download from the 4.62 download?

Printers work if you install them manually on the Windows 7 machines. The 64 bit print drivers do exist on the print servers. It is only the kix script that fails to install the printers.

Drive mappings and other scripts work, just not printer mappings. Perhaps this is the reason.



tjcarst
(Hey THIS is FUN)
2011-12-15 12:01 AM
Re: Printer mapping script not working in Windows 7

It appears as only Domain Local group membership is retrieved, not global.

I did see there was a hotfix from Microsoft, but I could not install it on the Windows 7 PC.

http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=196497


tjcarst
(Hey THIS is FUN)
2011-12-15 12:02 AM
Re: Printer mapping script not working in Windows 7

 Code:
$WS = GetObject('WinNT://' + @domain + '/' + @wksta + '$$')

if @error
   ? @serror
else

   for each $grp In $WS.Groups
      $GrpName = $grp.Name

        ? "Workstation groups: "$grp.Name
endif



This returns only Domain Local groups:

Workstation groups: Domain Computers
Workstation groups: Printer Setup DL Group

My PC is a member of the following Global Groups:

Printer Setup Group (must be in group to call printer setup script)
A04_q-mis1 (printer group)
D04_q-mis2 (printer group)

Do I need to change my printer setup groups to be Domain Local Groups to get Windows 7 pcs to obtain printers via Kix?


AllenAdministrator
(KiX Supporter)
2011-12-15 12:27 AM
Re: Printer mapping script not working in Windows 7

Lets start simple first. Please run this and give us your results...

 Code:
If addprinterconnection("your printer")=0
  ? "Printer Added"
else
  ? "Printer Not Added"
  ? @serror
endif


AllenAdministrator
(KiX Supporter)
2011-12-15 12:29 AM
Re: Printer mapping script not working in Windows 7

The hotfix was only for Win 7 PCs with a Windows 2000 Domain Controler, and was included in SP1 for Windows 7.

AllenAdministrator
(KiX Supporter)
2011-12-15 12:30 AM
Re: Printer mapping script not working in Windows 7

I was referring to 64bit print drivers. There is no kix64 yet.

tjcarst
(Hey THIS is FUN)
2011-12-15 04:40 PM
Re: Printer mapping script not working in Windows 7

Printer Added

AllenAdministrator
(KiX Supporter)
2011-12-15 04:55 PM
Re: Printer mapping script not working in Windows 7

You could be on to something... the NT provider might not be working as expected. Try using GetADUserGroups (it uses LDAP) and see if you get better results. The example in the header should be enough to find out if it gets better results....

GetADUserGroups() - http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=198609#Post198609

How to use UDFs -
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=81943#Post81943

The rest of the UDFs are here -
http://www.kixtart.org/forums/ubbthreads.php?ubb=postlist&Board=7&page=1



tjcarst
(Hey THIS is FUN)
2011-12-15 04:59 PM
Re: Printer mapping script not working in Windows 7

Changing the D04_q-mis2 Global Group to a Domain Local Group DOES work.

Workstation groups: Domain Computers
Workstation groups: D04_q-mis2
Workstation groups: Printer Setup DL Group

** Printers assigned through Printer Setup Group **

Default Printer: \\prn03\q-mis2


AllenAdministrator
(KiX Supporter)
2011-12-15 05:02 PM
Re: Printer mapping script not working in Windows 7

Curious though... how come you chose to do it this way instead of just using the built in INGROUP?

 Code:
if Ingroup("blah")
  $rc=addprinterconnection("printer")
endif


tjcarst
(Hey THIS is FUN)
2011-12-15 05:07 PM
Re: Printer mapping script not working in Windows 7

I need to map based upon Computer Group membership. I did not think Ingroup worked for Computers, only users.

I work at a hospital where the users move from floor to floor often. The printer must be physically close to the computer, not the user.


AllenAdministrator
(KiX Supporter)
2011-12-15 05:12 PM
Re: Printer mapping script not working in Windows 7

There is also...

Computeringroup() - http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=195717#Post195717


tjcarst
(Hey THIS is FUN)
2011-12-15 05:13 PM
Re: Printer mapping script not working in Windows 7

http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=46049&fpart=3

AllenAdministrator
(KiX Supporter)
2011-12-15 05:24 PM
Re: Printer mapping script not working in Windows 7

Your link is broke...

tjcarst
(Hey THIS is FUN)
2011-12-15 05:34 PM
Re: Printer mapping script not working in Windows 7

I am using ComputerInGroup to call the script that does the mapping.

 Code:
if ComputerInGroup('Printer Setup Group')=1
   call @ScriptDir+'\printers.kix'
endif


How do I use ComputerInGroup to enumerate all of the computer's group membership in my script?



http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=46049&fpart=1


AllenAdministrator
(KiX Supporter)
2011-12-15 05:37 PM
Re: Printer mapping script not working in Windows 7

I'm headed out... Maybe someone else can hop in here...

tjcarst
(Hey THIS is FUN)
2011-12-15 05:41 PM
Re: Printer mapping script not working in Windows 7

May have found something to try.

http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=201892


tjcarst
(Hey THIS is FUN)
2011-12-15 05:46 PM
Re: Printer mapping script not working in Windows 7

Same problem with EnumComputerinGroups. Only enumerates Domain Local groups on Windows 7.

ShaneEP
(MM club member)
2011-12-15 07:25 PM
Re: Printer mapping script not working in Windows 7

You mind running a test vb script?

Got it from this sight, which describes some potential errors encountered when using the memberof function, which is what EnumComputerInGroups and ComputerInGroup uses.

http://www.rlmueller.net/MemberOf.htm

Not sure if it's helpful, but it's something.

 Code:
Set objSysInfo = CreateObject("ADSystemInfo")
strUserDN = objSysInfo.computername
Set objUser = GetObject("LDAP://" & strUserDN)
On Error Resume Next
arrGroups = objUser.GetEx("memberOf")
If (Err.Number <> 0) Then
    On Error GoTo 0
    Wscript.Echo "Member of no groups"
Else
    On Error GoTo 0
    For Each strGroup In arrGroups
        Wscript.Echo "Member of group " & strGroup
    Next
End If


tjcarst
(Hey THIS is FUN)
2011-12-15 07:32 PM
Re: Printer mapping script not working in Windows 7

ShaneEP:

Results of script:
ERROR : IDispatch pointers not allowed in expressions!
Script: X:\test.KIX
Line : 2


tjcarst
(Hey THIS is FUN)
2011-12-15 07:35 PM
Re: Printer mapping script not working in Windows 7

Oops. Not a kix script.

Running it as a vb yields the domain local groups only.


ShaneEP
(MM club member)
2011-12-15 07:38 PM
Re: Printer mapping script not working in Windows 7

Well atleast we know its not a kix issue. Have your tried using WinNT instead of LDAP?

tjcarst
(Hey THIS is FUN)
2011-12-15 07:42 PM
Re: Printer mapping script not working in Windows 7

Windows XP returns all groups, domain local and global.

tjcarst
(Hey THIS is FUN)
2011-12-15 07:46 PM
Re: Printer mapping script not working in Windows 7

This is what I am using:

 Code:
$WS = GetObject('WinNT://' + @domain + '/' + @wksta + '$$')

   for each $grp In $WS.Groups
      $GrpName = $grp.Name


ShaneEP
(MM club member)
2011-12-15 08:02 PM
Re: Printer mapping script not working in Windows 7

Oh yeah, sorry I missed that on the first page.

It just doesn't make much sense to me that it worked on XP and not Win7. I'm assuming nothing changed on the server side?


tjcarst
(Hey THIS is FUN)
2011-12-15 08:18 PM
Re: Printer mapping script not working in Windows 7

The script has not changed. Two pcs with same group membership.



XP results:
Workstation groups: ITS Computers
Workstation groups: Automatic Updates Computers
Workstation groups: Domain Computers
Workstation groups: Printer Setup Group
Workstation groups: A04_q-mis1
Workstation groups: Windows Updates Computers
Workstation groups: Printer Setup DL Group
Workstation groups: D04_q-mis2

Windows 7 results: (these are all Domain Local groups)
Workstation groups: Domain Computers
Workstation groups: D04_q-mis2
Workstation groups: Printer Setup DL Group


AllenAdministrator
(KiX Supporter)
2011-12-15 11:28 PM
Re: Printer mapping script not working in Windows 7

I have not tested this, so there could be an bug or few. Try it out see what you get.

for each $group in GetADComputerGroups()
  ? $group
next
 

function GetADComputerGroups() dim $objSysInfo,$objcomputer,$groups,$group,$array[0],$i $computeringroup=0 $objSysInfo=CreateObject("ADSystemInfo") $objComputer=getobject("LDAP://" + $objSysinfo.computername) $Groups = $objComputer.GetEx("memberOf") for each $group in $groups redim preserve $array[$i] $array[$i]=GetObject("LDAP://" + $Group).cn $i=$i+1 next $GetADComputerGroups=$array endfunction


tjcarst
(Hey THIS is FUN)
2011-12-16 09:36 PM
Re: Printer mapping script not working in Windows 7

Thank you, Allen.

I am home today fighting a crappy cold. I will test this on Monday and let you know results.


NTDOCAdministrator
(KiX Master)
2011-12-16 10:58 PM
Re: Printer mapping script not working in Windows 7

On XP with Server 2003 AD this comes back empty for me Allen

AllenAdministrator
(KiX Supporter)
2011-12-16 11:01 PM
Re: Printer mapping script not working in Windows 7

Just to be sure, you have the computer (not user) in some groups?

NTDOCAdministrator
(KiX Master)
2011-12-19 08:19 AM
Re: Printer mapping script not working in Windows 7

Ah.. didn't even think about that Allen you're probably right. I may not have any stations in groups at this time. I did have at one point but think I've since removed them.

If I have time I'll add some and test it again.

Thanks


tjcarst
(Hey THIS is FUN)
2011-12-19 05:27 PM
Re: Printer mapping script not working in Windows 7

GetADComputerGroups on Win7 only retrieves Domain Local Groups too.

AllenAdministrator
(KiX Supporter)
2011-12-19 07:36 PM
Re: Printer mapping script not working in Windows 7

I don't know if this is the same thing or not... but here is something I found for your reading pleasure.

http://networkadminkb.com/KB/a9/group-enumeration-between-trusted-domains-does-not.aspx


tjcarst
(Hey THIS is FUN)
2012-01-06 08:54 PM
Re: Printer mapping script not working in Windows 7

Thank you. Looks like I will be changing group types.

tjcarst
(Hey THIS is FUN)
2012-01-06 08:57 PM
Re: Printer mapping script not working in Windows 7

Reading that article indicates not all Domain Local groups are enumerated. My groups are Global groups. Changing my Global to Domain Local allows the script to run. The article suggests using Universal groups, not Domain Local.