Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Vista Printing / Faxing / Scanning > PaperSize not available when Run as Admin

Reply
Thread Tools Display Modes

PaperSize not available when Run as Admin

 
 
robkeithd
Guest
Posts: n/a

 
      05-22-2009

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
 
Reply With Quote
 
 
 
 
Alan Morris [MSFT]
Guest
Posts: n/a

 
      05-28-2009
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" <> wrote in message
news:...
>
> 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



 
Reply With Quote
 
robkeithd
Guest
Posts: n/a

 
      05-28-2009

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.


--
robkeithd
 
Reply With Quote
 
Alan Morris [MSFT]
Guest
Posts: n/a

 
      05-28-2009
You can change the timeout value on the splwow64.exe for termination after 1
minute. If the print driver keeps a reference to the process this does not
work.


http://support.microsoft.com/kb/923357

You cannot use the RUNAS command to print from a 32-bit program in different
user accounts in a single session on a computer that is running a 64-bit
version of Microsoft Windows



--
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" <> wrote in message
news:...
>
> 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.
>
>
> --
> robkeithd



 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Printdriver: problem with papersize and FileMaker gduifhuis Windows Vista Drivers 0 10-29-2007 07:13 PM
Printer GPD *Feature: PaperSize M-u-p-o-p-a Windows Vista Drivers 0 04-26-2006 07:09 PM
UniDriver plugin -- "custom papersize" does not appear in my DEVMODE Rudy Windows Vista Drivers 1 02-20-2006 04:46 AM
Print driver: Removing PaperSize definitions rockyh Windows Vista Drivers 2 06-22-2004 02:13 PM
Unidriver PaperSize feature rockyh Windows Vista Drivers 1 06-21-2004 03:38 PM



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 47 48 49 50 51 52 53 54 55 56 57 58 59