#205987 - 2012-10-11 03:39 PM
Windows 7 addprinterconnection also setting default?
|
syntax53
Fresh Scripter
Registered: 2004-11-17
Posts: 33
Loc: Pennsylvania
|
Hello,
Just starting to test out the use of "ADDPRINTERCONNECTION" for the first time. What I'm seeing is on the windows 7 computers, while the printer connection is adding successfully, it's also setting the printer as the default. It's hard to search on these forums / the internet for people with similar issues because pretty much all of the results are people WANTING to set the default printer, where as I do not want to. Any ideas? tia
p.s. The same script running on windows xp works as expected. It just adds the additional connection and doesn't change the original default printer (what we want).
|
Top
|
|
|
|
#205991 - 2012-10-11 04:09 PM
Re: Windows 7 addprinterconnection also setting default?
[Re: Allen]
|
syntax53
Fresh Scripter
Registered: 2004-11-17
Posts: 33
Loc: Pennsylvania
|
ADDPRINTERCONNECTION ("\\hi2\hifacultycopier")
ADDPRINTERCONNECTION ("\\hi2\hiofficecopier")
That's it. Of course I have other stuff that I run, but as a test I made a script that is that and only that. Now I will say that while I haven't been able to replicate the problem on XP at all (it always works as expected on XP), it DOES work as expected on my own machine Windows 7 machine (UAC off though) (adds the printer without changing the default). However, on 2 different clients that I've tested so far (both Windows 7 pro 64-bit with UAC turned ON, both same model computer built from same image, but in different domains) it changes the default.
And actually I just noticed while I was typing this that the default was changed to the faculty copier, which is the first line in the script. So that's weird. I'll play around with the order and see if there is any difference.
Edited by syntax53 (2012-10-11 04:10 PM)
|
Top
|
|
|
|
#205993 - 2012-10-11 04:19 PM
Re: Windows 7 addprinterconnection also setting default?
[Re: syntax53]
|
syntax53
Fresh Scripter
Registered: 2004-11-17
Posts: 33
Loc: Pennsylvania
|
So I modified the script to this:
;FROM http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=118766
function GetDefaultPrinter()
$GetDefaultPrinter = join(split(readvalue("HKEY_USERS\"+@sid+"\Software\Microsoft\Windows NT\CurrentVersion\Windows","Device"),',',1),'')
endfunction
$a = GetDefaultPrinter
$r1 = ADDPRINTERCONNECTION ("\\hi2\hifacultycopier")
$b = GetDefaultPrinter
$r2 = ADDPRINTERCONNECTION ("\\hi2\hiofficecopier")
$c = GetDefaultPrinter
OPEN (1, '%USERPROFILE%' + '\test.txt', 5)
WRITELINE (1, $a + @CRLF)
WRITELINE (1, $r1 + @CRLF)
WRITELINE (1, $b + @CRLF)
WRITELINE (1, $r2 + @CRLF)
WRITELINE (1, $c + @CRLF)
CLOSE (1)
And this is the output:
RM 206 Mono
0\\hi2\HI Faculty Copier
0\\hi2\HI Faculty Copier
Yet if I run the same exact script on my machine:
Technology Color
0Technology Color
0Technology Color
EDIT: Switching the order switches which one gets set to the default. So whichever the first one is is getting set as the default. So it seems to me that for whatever reason maybe it doesn't think a default printer is set and is therefor setting it?
EDIT2: same result if I run the script from a command line (instead of via logon script)
Edited by syntax53 (2012-10-11 04:27 PM)
|
Top
|
|
|
|
#205994 - 2012-10-11 04:24 PM
Re: Windows 7 addprinterconnection also setting default?
[Re: syntax53]
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4545
Loc: USA
|
Try this just to see if what you think is happening, is really happening.
if ADDPRINTERCONNECTION("\\hi2\hifacultycopier")=0
"Printer Added"
else
"Printer Not Added - " + @serror
endif
I know nothing about your environment, but keep in mind that you have to have both the 32 and 64 bit printer drivers installed on your printer server, and those drivers have to be identical in name and version.
|
Top
|
|
|
|
#205995 - 2012-10-11 04:30 PM
Re: Windows 7 addprinterconnection also setting default?
[Re: Allen]
|
syntax53
Fresh Scripter
Registered: 2004-11-17
Posts: 33
Loc: Pennsylvania
|
I know nothing about your environment, but keep in mind that you have to have both the 32 and 64 bit printer drivers installed on your printer server, and those drivers have to be identical in name and version. I know the script is adding the printers and the drivers and I'm sure the driver (64bit) is on the server. These clients never had these printers (network copiers) that I'm adding, nor any other printer of the same model and I'm removing the printers after the script runs every time while testing it.
|
Top
|
|
|
|
#205997 - 2012-10-11 04:48 PM
Re: Windows 7 addprinterconnection also setting default?
[Re: Mart]
|
Lonkero
KiX Master Guru
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
|
Top
|
|
|
|
#205998 - 2012-10-11 04:55 PM
Re: Windows 7 addprinterconnection also setting default?
[Re: Lonkero]
|
syntax53
Fresh Scripter
Registered: 2004-11-17
Posts: 33
Loc: Pennsylvania
|
So I modified the script to this to fix it:
;FROM http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=118766
function GetDefaultPrinter()
$GetDefaultPrinter = join(split(readvalue("HKEY_USERS\"+@sid+"\Software\Microsoft\Windows NT\CurrentVersion\Windows","Device"),',',1),'')
endfunction
$dp1 = GetDefaultPrinter
$r = ADDPRINTERCONNECTION ("\\hi2\hiofficecopier")
$r = ADDPRINTERCONNECTION ("\\hi2\hifacultycopier")
$dp2 = GetDefaultPrinter
IF NOT $dp1 = $dp2
$r = SETDEFAULTPRINTER($dp1)
ENDIF
Kind of a hack, but it works.
edit: edited to include UDF for completeness.
Edited by syntax53 (2012-10-12 02:10 PM)
|
Top
|
|
|
|
#205999 - 2012-10-11 05:05 PM
Re: Windows 7 addprinterconnection also setting default?
[Re: Lonkero]
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4545
Loc: USA
|
Interesting.... I've never come across this problem. Also interesting is the first link Lonk linked to, talks about clicking on "Manage Default Printers" button. I don't have that button at all on my desktop. Another site suggest disabling the change with reg hack...
writevalue("hkcu\Printers\Defaults","Disabled",1,"REG_DWORD")
http://www.normanbauer.com/2011/03/11/how-to-disable-windows-7s-default-printer-management/
|
Top
|
|
|
|
#206009 - 2012-10-12 02:14 PM
Re: Windows 7 addprinterconnection also setting default?
[Re: ShaneEP]
|
syntax53
Fresh Scripter
Registered: 2004-11-17
Posts: 33
Loc: Pennsylvania
|
What version of Kix are you using? I only ask because wan't there changes to the printer portions in the newest release?
"KiXtart 2010 4.62"
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 259 anonymous users online.
|
|
|