How to pipe the output of a command to the printer in Windows 10


  1. Posts : 2
    Windows 10 Version 20H2 (Os Build 19042.1466)
       #1

    How to pipe the output of a command to the printer in Windows 10


    I'm at the command line.
    I want the output of the "set" command to go directly to my printer. I tried the following:

    set | notepad.exe

    I expected the output of the set command to become input to the notepad.exe command
    which then would print it out. Instead I get a blank notepad screen.
    I know the following works:

    set > filex
    notepad.exe filex

    This brings up the filex contents in notepad, which I can then print out.
    I would prefer to do it with one command.
      My Computer


  2. Posts : 3,446
       #2

    $Content ="Some text"
    Set-Content -Path "myfile.txt" -Value $Content
    Invoke-Item "myfile.txt"

    Edit: I misread the requirement... is this what you want?

    #Print the file to default printer
    Get-Content -Path "myfile.txt" | Out-Printer
    Last edited by Superfly; 26 Aug 2016 at 06:13.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd
All times are GMT -5. The time now is 14:39.
Find Us




Windows 10 Forums