Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Vista Newsgroups > Vista print fax & scan

Vista - PaperSize not available when Run as Admin

Reply
 
Old 05-22-2009   #1 (permalink)


Vista Busniess 64
 
 

PaperSize not available when Run as Admin

I've got a Windows app written in C# that errors out when it is Run as Admin. I've boiled it down to setting the PaperSize on the printer. I've got a test app consisting of single form with two textboxes and in the Shown event I have the following code:

PrinterSettings ps = new PrinterSettings();
ps.PrinterName = "Microsoft XPS Document Writer";
textBox1.Text = ps.PrinterName;
textBox2.Text = ps.PaperSizes.Count.ToString();

When I run the app with a double click on the desktop icon I get the expected 106 for the count. If I right click the icon and select Run as Admin, the printer name is correct but the count is zero.

Part of my full app relies on reading the PaperSizes so the issue of not finding any when running as admin is causing some problems. This only seems to be an issue on 64 bit Vista. Have reproduced it on two 64 bit boxes but don't have the problem on a 32 bit Vista or XP 32 or XP 64.

Any help on this would be greatly appreciated

Thanks

My System SpecsSystem Spec
Old 05-28-2009   #2 (permalink)
Alan Morris [MSFT]


 
 

Re: PaperSize not available when Run as Admin

is this a 32bit application?

--
Alan Morris
Windows Printing Team
Search the Microsoft Knowledge Base here:
http://support.microsoft.com/search/?adv=1

This posting is provided "AS IS" with no warranties, and confers no rights.

"robkeithd" <guest@xxxxxx-email.com> wrote in message
news:e3a413d48d7036ec60340f977026c0f9@xxxxxx-gateway.com...
Quote:

>
> I've got a Windows app written in C# that errors out when it is Run as
> Admin. I've boiled it down to setting the PaperSize on the printer.
> I've got a test app consisting of single form with two textboxes and in
> the Shown event I have the following code:
>
> PrinterSettings ps = new PrinterSettings();
> ps.PrinterName = "Microsoft XPS Document Writer";
> textBox1.Text = ps.PrinterName;
> textBox2.Text = ps.PaperSizes.Count.ToString();
>
> When I run the app with a double click on the desktop icon I get the
> expected 106 for the count. If I right click the icon and select Run as
> Admin, the printer name is correct but the count is zero.
>
> Part of my full app relies on reading the PaperSizes so the issue of
> not finding any when running as admin is causing some problems. This
> only seems to be an issue on 64 bit Vista. Have reproduced it on two 64
> bit boxes but don't have the problem on a 32 bit Vista or XP 32 or XP
> 64.
>
> Any help on this would be greatly appreciated
>
> Thanks
>
>
> --
> robkeithd

My System SpecsSystem Spec
Old 05-28-2009   #3 (permalink)


Vista Busniess 64
 
 

Re: PaperSize not available when Run as Admin

Hi Alan,

Thanks for the reply

Our "real" app is 32 bit. I built the test app as both 32 and 64. We have been done a little more discovery. This seems to have something to do with splwow64.exe. If I run the test "as is" and then it again "as admin" I have the problem. If I bring up Task Manager and kill splwow64 (or wait long enough for it go away on its own) in between then the test runs fine. If I run "as admin" the first time then I don't seem to have the problem - i.e. I can turn right around and run the app as is or as admin with no problem.

So now I'm at the point where I know I need to make sure I can read the printer properties before proceeeding with the print job so my program won't just flat out die but I don't really know what to do if it turns out that I can't read the properites.

If there is some trick or tip out there it would be greatly appreiciated.
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
How to set Admin password from an admin user account Vista General
Launching process with Admin Credentials with out prompting user for Admin password PowerShell
Beyond a normal Admin issue. Admin account is acting as a guest ac Vista account administration
Admin access to Vista Registry Remote & locally in Admin Approval Vista security
Add domain admin to local admin group Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46