Page 1 of 3 123>
Topic Options
#203920 - 2011-12-14 08:15 PM Printer mapping script not working in Windows 7
tjcarst Offline
Hey THIS is FUN

Registered: 2003-09-08
Posts: 243
Loc: USA
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



Edited by tjcarst (2011-12-14 08:21 PM)

Top
#203921 - 2011-12-14 09:18 PM Re: Printer mapping script not working in Windows 7 [Re: tjcarst]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4548
Loc: USA
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.

Top
#203922 - 2011-12-14 09:29 PM Re: Printer mapping script not working in Windows 7 [Re: Allen]
tjcarst Offline
Hey THIS is FUN

Registered: 2003-09-08
Posts: 243
Loc: USA
This is not a gpo startup script. I call it from kix.bat on the user profile settings tab.

Thanks!

Top
#203923 - 2011-12-14 09:30 PM Re: Printer mapping script not working in Windows 7 [Re: tjcarst]
tjcarst Offline
Hey THIS is FUN

Registered: 2003-09-08
Posts: 243
Loc: USA
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.
Top
#203924 - 2011-12-14 09:47 PM Re: Printer mapping script not working in Windows 7 [Re: tjcarst]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4548
Loc: USA
Are the Win7 pcs 64bit? If so, you have to have the 64bit drivers installed on the server as well.
Top
#203925 - 2011-12-14 10:03 PM Re: Printer mapping script not working in Windows 7 [Re: Allen]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4548
Loc: USA
Also, what is the @serror returned after the addprinterconnection() line.
Top
#203926 - 2011-12-14 11:52 PM Re: Printer mapping script not working in Windows 7 [Re: Allen]
tjcarst Offline
Hey THIS is FUN

Registered: 2003-09-08
Posts: 243
Loc: USA
No error gets returned.
Top
#203927 - 2011-12-14 11:52 PM Re: Printer mapping script not working in Windows 7 [Re: tjcarst]
tjcarst Offline
Hey THIS is FUN

Registered: 2003-09-08
Posts: 243
Loc: USA
Yes, 64-bit Windows 7.
Top
#203928 - 2011-12-14 11:53 PM Re: Printer mapping script not working in Windows 7 [Re: Allen]
tjcarst Offline
Hey THIS is FUN

Registered: 2003-09-08
Posts: 243
Loc: USA
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.



Edited by tjcarst (2011-12-14 11:55 PM)

Top
#203929 - 2011-12-15 12:01 AM Re: Printer mapping script not working in Windows 7 [Re: tjcarst]
tjcarst Offline
Hey THIS is FUN

Registered: 2003-09-08
Posts: 243
Loc: USA
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

Top
#203930 - 2011-12-15 12:02 AM Re: Printer mapping script not working in Windows 7 [Re: tjcarst]
tjcarst Offline
Hey THIS is FUN

Registered: 2003-09-08
Posts: 243
Loc: USA
 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?


Edited by tjcarst (2011-12-15 12:07 AM)

Top
#203931 - 2011-12-15 12:27 AM Re: Printer mapping script not working in Windows 7 [Re: tjcarst]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4548
Loc: USA
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


Edited by Allen (2011-12-15 01:37 AM)

Top
#203932 - 2011-12-15 12:29 AM Re: Printer mapping script not working in Windows 7 [Re: Allen]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4548
Loc: USA
The hotfix was only for Win 7 PCs with a Windows 2000 Domain Controler, and was included in SP1 for Windows 7.

Edited by Allen (2011-12-15 12:43 AM)

Top
#203933 - 2011-12-15 12:30 AM Re: Printer mapping script not working in Windows 7 [Re: Allen]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4548
Loc: USA
I was referring to 64bit print drivers. There is no kix64 yet.
Top
#203934 - 2011-12-15 04:40 PM Re: Printer mapping script not working in Windows 7 [Re: Allen]
tjcarst Offline
Hey THIS is FUN

Registered: 2003-09-08
Posts: 243
Loc: USA
Printer Added
Top
#203935 - 2011-12-15 04:55 PM Re: Printer mapping script not working in Windows 7 [Re: tjcarst]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4548
Loc: USA
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


Top
#203936 - 2011-12-15 04:59 PM Re: Printer mapping script not working in Windows 7 [Re: tjcarst]
tjcarst Offline
Hey THIS is FUN

Registered: 2003-09-08
Posts: 243
Loc: USA
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

Top
#203937 - 2011-12-15 05:02 PM Re: Printer mapping script not working in Windows 7 [Re: tjcarst]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4548
Loc: USA
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

Top
#203938 - 2011-12-15 05:07 PM Re: Printer mapping script not working in Windows 7 [Re: Allen]
tjcarst Offline
Hey THIS is FUN

Registered: 2003-09-08
Posts: 243
Loc: USA
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.

Top
#203939 - 2011-12-15 05:12 PM Re: Printer mapping script not working in Windows 7 [Re: tjcarst]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4548
Loc: USA
There is also...

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

Top
Page 1 of 3 123>


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

Who's Online
0 registered and 338 anonymous users online.
Newest Members
Jojo67, MaikSimon, kvn317, kixtarts2025, SERoyalty
17873 Registered Users

Generated in 0.077 seconds in which 0.024 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