Powershell or VBS to print file already opened by Internet Explorer

Sunny Wong 1 Reputation point
2021-10-26T02:38:48.64+00:00

Visio file (vsd extension), unfortunately, to print needs File Open as prerequisite.; can't be printed by Windows 10 File Explorer Right-Click-Print.

File Open to print becomes tedious with numerous such files.
I have script to drop file into PS script to open file with IE; but have not figure out script to

  1. save file (timestamping original name ) already opened by IE
  2. setup page layout
  3. prompt user to send to printer
  4. print

This is Windows 10 Enterprise.

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,322 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Rich Matheisen 44,416 Reputation points
    2021-10-26T14:52:40.27+00:00

    Visio has command line switches and parameters. Have you tried using them?

    0 comments No comments

  2. Limitless Technology 39,296 Reputation points
    2021-10-27T08:03:53.687+00:00

    Hi there,

    The Invoke-Item cmdlet performs the default action on the specified item. For example, it runs an executable file or opens a document file in the application associated with the document file type.

    This command opens all of the Microsoft Office Excel spreadsheets in the C:\Documents and Settings\Lister\My Documents folder. Each spreadsheet is opened in a new instance of Excel. In this case, opening in Excel is the default action for .xls files.

    Invoke-Item "C:\Documents and Settings\Lister\My Documents*.xls"

    https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/invoke-item?view=powershell-7.1

    ------------------------------------------------------------------------------------------------------------------------------------------------------

    --If the reply is helpful, please Upvote and Accept it as an answer--


  3. Sunny Wong 1 Reputation point
    2021-10-27T08:04:31.82+00:00

    My job not expected to need Visio; waiting for approval to get Visio.

    With no app to try, i can only find
    [command-line-switches-for-microsoft-visio-2010-f1de9af3-8368-4ef0-9a2f-25d430ec5576][1].
    which didn't mention anything for printing.

    I have yet found "Command-line switches for Microsoft Visio 365"

    If you know where, I appreciate info.


  4. Rich Matheisen 44,416 Reputation points
    2021-10-27T14:56:33.387+00:00

    You would probably have more success using an IE COM object.

    To print to your default printer, use something like this "$IE.ExecWB(6,2)"