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 > Misc Newsgroups > PowerShell

Vista - printing a file created by the windows printing dialog (print to f

Reply
 
Old 06-16-2009   #1 (permalink)
jho


 
 

printing a file created by the windows printing dialog (print to f

Hi,

I have printed a PDF-File by using the Windows print dialog using the option
"print to file".

In the windows command processor I can print this file with:
copy /b "c:\test.prn" \\servername\printername

The question now was, how can I do this in powershell?

My idea was:
get-content -path "c:\test.prn" | out-printer

But this only works if the file is a textfile.
A switch like /b (binary) as for the copy-command dosent exist in powershell.
I think a similar parameter for the get-content cmdlet should be -encoding,
but there is no value possible that equals binary.

Has anybody an idea how to get the problem solved?

Many thaks in advance.

jho



My System SpecsSystem Spec
Old 06-16-2009   #2 (permalink)
Vadims Podans [MVP]


 
 

Re: printing a file created by the windows printing dialog (print to f

powershell have full support for CMD command. As example:
cmd /c "copy /b "c:\test.prn" \\servername\printername"
--
WBR, Vadims Podans
MVP: PowerShell
PowerShell blog - www.sysadmins.lv

"jho" <jho@xxxxxx> rakstīja ziņojumā
"news:8D484684-F62F-4B2F-9637-80D77441C3AE@xxxxxx"...
Quote:

> Hi,
>
> I have printed a PDF-File by using the Windows print dialog using the
> option
> "print to file".
>
> In the windows command processor I can print this file with:
> copy /b "c:\test.prn" \\servername\printername
>
> The question now was, how can I do this in powershell?
>
> My idea was:
> get-content -path "c:\test.prn" | out-printer
>
> But this only works if the file is a textfile.
> A switch like /b (binary) as for the copy-command dosent exist in
> powershell.
> I think a similar parameter for the get-content cmdlet should
> be -encoding,
> but there is no value possible that equals binary.
>
> Has anybody an idea how to get the problem solved?
>
> Many thaks in advance.
>
> jho
>
>
My System SpecsSystem Spec
Old 06-17-2009   #3 (permalink)
jho


 
 

Re: printing a file created by the windows printing dialog (print

Many thanks Mr. Podans, but I want to know how do I this with the cmdlets of
powerschell.

"Vadims Podans [MVP]" wrote:
Quote:

> powershell have full support for CMD command. As example:
> cmd /c "copy /b "c:\test.prn" \\servername\printername"
> --
> WBR, Vadims Podans
> MVP: PowerShell
> PowerShell blog - www.sysadmins.lv
>
> "jho" <jho@xxxxxx> rakstīja ziņojumā
> "news:8D484684-F62F-4B2F-9637-80D77441C3AE@xxxxxx"...
Quote:

> > Hi,
> >
> > I have printed a PDF-File by using the Windows print dialog using the
> > option
> > "print to file".
> >
> > In the windows command processor I can print this file with:
> > copy /b "c:\test.prn" \\servername\printername
> >
> > The question now was, how can I do this in powershell?
> >
> > My idea was:
> > get-content -path "c:\test.prn" | out-printer
> >
> > But this only works if the file is a textfile.
> > A switch like /b (binary) as for the copy-command dosent exist in
> > powershell.
> > I think a similar parameter for the get-content cmdlet should
> > be -encoding,
> > but there is no value possible that equals binary.
> >
> > Has anybody an idea how to get the problem solved?
> >
> > Many thaks in advance.
> >
> > jho
> >
> >
>
My System SpecsSystem Spec
Old 06-18-2009   #4 (permalink)
Vadims Podans [MVP]


 
 

Re: printing a file created by the windows printing dialog (print

Get-Content cmdlet has -Encoding paramter in PowerShell V2. In PowerShell
1.0 you can use readAllText method in io.file class:
http://msdn.microsoft.com/en-us/library/ms143369.aspx
--
WBR, Vadims Podans
MVP: PowerShell
PowerShell blog - www.sysadmins.lv

"jho" <jho@xxxxxx> rakstīja ziņojumā
"newsFAC9497-5BE7-44FA-B1B6-99CBDE4E2CA3@xxxxxx"...
Quote:

> Many thanks Mr. Podans, but I want to know how do I this with the cmdlets
> of
> powerschell.
>
> "Vadims Podans [MVP]" wrote:
>
Quote:

>> powershell have full support for CMD command. As example:
>> cmd /c "copy /b "c:\test.prn" \\servername\printername"
>> --
>> WBR, Vadims Podans
>> MVP: PowerShell
>> PowerShell blog - www.sysadmins.lv
>>
>> "jho" <jho@xxxxxx> rakstīja ziņojumā
>> "news:8D484684-F62F-4B2F-9637-80D77441C3AE@xxxxxx"...
Quote:

>> > Hi,
>> >
>> > I have printed a PDF-File by using the Windows print dialog using the
>> > option
>> > "print to file".
>> >
>> > In the windows command processor I can print this file with:
>> > copy /b "c:\test.prn" \\servername\printername
>> >
>> > The question now was, how can I do this in powershell?
>> >
>> > My idea was:
>> > get-content -path "c:\test.prn" | out-printer
>> >
>> > But this only works if the file is a textfile.
>> > A switch like /b (binary) as for the copy-command dosent exist in
>> > powershell.
>> > I think a similar parameter for the get-content cmdlet should
>> > be -encoding,
>> > but there is no value possible that equals binary.
>> >
>> > Has anybody an idea how to get the problem solved?
>> >
>> > Many thaks in advance.
>> >
>> > jho
>> >
>> >
>>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Printing small file turns in to huge file in print queue Vista General
Error in Printing using "Print To File" and RAW Print mode Vista print fax & scan
How do I stop Vista using print to file as default when printing Vista General
Fix for printing Works doc created another problem (Vista) Vista General
Printing to printers on a windows 2003 print server Vista networking & sharing


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