rundll32 + printui.dll: Printername as variable?

FragenFrager
Member Posts: 69
Hello,
at the moment, I'm trying to change the system printer from NAV by the rundll32 + printui.dll.
Basically, it works. Hovewer, I can't pass the printer name as a variable :-k
Here is the code:
The command, where I pass the printername \\minastirith\IBM Infoprint 1532PS2 directly works. When I try to run the command with the Printername as Variable %gtxReportPrinter%, I get an errormessage which says that the printername ist incorrect or connection to server is down.
I tried different ways to put the printername together, with quotation marks and without, with one blank after the /n parameter and, finally, with the percent-sign as below.
Anyone an Idea? It won't be a good Idea to hard-code the printername in the programm, I think.
With kind regards
at the moment, I'm trying to change the system printer from NAV by the rundll32 + printui.dll.
Basically, it works. Hovewer, I can't pass the printer name as a variable :-k
Here is the code:
IF ISCLEAR(WShShell) THEN CREATE(WShShell); RegKey := 'HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device'; gtxDefaultPrinter := WShShell.RegRead(RegKey); ginPos:=STRPOS(gtxDefaultPrinter,','); gtxDefaultPrinter:=DELSTR(gtxDefaultPrinter,ginPos); gtxReportPrinter:=gcuAppM.FindPrinter(50001); gtxReportPrinter:='"'+gtxReportPrinter+'"'; WShShell.Run('rundll32 printui.dll,PrintUIEntry /y /n%gtxReportPrinter%'); //WShShell.Run('rundll32 printui.dll,PrintUIEntry /y /n"\\minastirith\IBM Infoprint 1532 PS3"'); CLEAR(WShShell);
The command, where I pass the printername \\minastirith\IBM Infoprint 1532PS2 directly works. When I try to run the command with the Printername as Variable %gtxReportPrinter%, I get an errormessage which says that the printername ist incorrect or connection to server is down.
I tried different ways to put the printername together, with quotation marks and without, with one blank after the /n parameter and, finally, with the percent-sign as below.
Anyone an Idea? It won't be a good Idea to hard-code the printername in the programm, I think.
With kind regards
0
Comments
-
[Topic moved from 'NAV Tips & Tricks' forum to 'NAV/Navision Classic Client' forum]Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
There is no automatic variable substitution in NAV. Please use STRSUBSTNO instead
WShShell.Run(STRSUBSTNO('rundll32 printui.dll,PrintUIEntry /y /n%1',gtxReportPrinter);
or use + to concatenate the stringWShShell.Run('rundll32 printui.dll,PrintUIEntry /y /n'+gtxReportPrinter);
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions