WordPad printing with RunProgram...

Just starting out? Need help? Post your questions and find answers here.
User avatar
blueb
Addict
Addict
Posts: 1044
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

WordPad printing with RunProgram...

Post by blueb »

I'm using Windows Pro 10 (64bit).

Since I have WordPad(Write.exe) installed on my machine by default, I have been trying
to find a way to print 'RTF files' from the command-line using RunProgram()

Doing some reading, I've read that...
#1 - To print any supported 'Text' File to the Default Printer

#2 - To print a compatible .doc, .rtf, .txt, .wri or other document right to
your default printer, simply open up a DOS window (Or click "Start > Run")
and type the command "write.exe /p filename".
This command line utility will automatically send the document you choose to your Default printer.

#3 - Sometimes, you may want to print a Wordpad-compatible document to another printer in
your home or office network. To specify a printer other than your default printer click on:
"Start," choose "Run" and type "write.exe /pt TextFileName PrinterName [ DriverName [ PortName ] ]".
Alternatively, you can open up a DOS window and type the same command.

; So my Choices:
; #1 - "write.exe filename" from the command line.
; #2 - Print to the Default Printer - "write.exe /p filename"
; #3 - Print to another Printer - "write.exe /pt TextFileName PrinterName [ DriverName [ PortName ] ]"

This is what I have, so far:

Code: Select all

FileName.s = GetCurrentDirectory() + "Xtras.rtf"
Debug FileName
Result = RunProgram("write.exe", "/p", FileName, #PB_Program_Wait|#PB_Program_Hide)
WordPad opens up, but prints a blank page. Perhaps there are other WordPad (Write.exe) command-line switches, but I haven't been able to locate any.

Maybe there's a completely different solution to print RTF files? :?:
- It was too lonely at the top.

System : PB 6.10 LTS (x64) and Win Pro 11 (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: WordPad printing with RunProgram...

Post by srod »

Try :

Code: Select all

RunProgram("write.exe", "/p " + FileName, "", #PB_Program_Wait|#PB_Program_Hide)
I may look like a mule, but I'm not a complete ass.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4663
Joined: Sun Apr 12, 2009 6:27 am

Re: WordPad printing with RunProgram...

Post by RASHAD »

Try

Code: Select all

FileName.s = "d:\onestop.txt"
Result = RunProgram("write.exe", "/p "+Chr(34)+ FileName +Chr(34),"", #PB_Program_Wait|#PB_Program_Hide)
Egypt my love
User avatar
blueb
Addict
Addict
Posts: 1044
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Re: WordPad printing with RunProgram...

Post by blueb »

Thanks fellas..

Thanks srod.. It was close, but not quite.

Rashad... "Perfect".

I remember seeing this Chr(34) solution that another user was having problems with and it never even occurred to me to try that!

Thanks again. :D
- It was too lonely at the top.

System : PB 6.10 LTS (x64) and Win Pro 11 (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
Post Reply