5

I am using Powershell 2.0 on Windows 7 SP1, but any answers covering versions 1.0-4.0 would be nice.

I know that this command opens Paint via PowerShell:

& "C:\Windows\system32\mspaint.exe"  

I know that this command opens Paint with a specific image via PowerShell:

& "C:\Windows\system32\mspaint.exe" "C:\Images\RHZv84o - Imgur.jpg" 

What I want to know is if in Powershell can I invoke the commands of this executable like print, save, or save as? Can I do the same for any program with its own specific commands?

For example if I open wmplayer.exe (Windows Media Player) with video (same format as paint with image), it opens and plays immediately. I want to instead open the video and use any of its commands like Ctrl + P to pause the video or Ctrl + N to create a new playlist?

The goal is to determine from Powershell, since some executables can be opened with objects, can some or all executables be opened and invoke actions (at least the ones with shortcut keys)?

  • 1
    an application must support an API en.wikipedia.org/wiki/Application_programming_interface or allow arguments to be passed. Windows Paint is like the most simple paint application ever made and it is not possible with it... you would need another paint program like GIMP/imagemagick. – Logman Oct 7 '14 at 0:59
  • @Logman By the first "it", do you mean specifically "print/save/save as"? Paint is just for example of opening an executable that also happens to support arguments for opening with a specific object. My goal is determine if it it or any other .exe can have its default capabilities used from PowerShell like Windows Media Player() opens it, WMPlayer(video.avi) opens and plays, but I wanna invoke its "Ctrl + P" to toggle pause. – Daz C Oct 7 '14 at 11:11
2

If the program has shell verbs like Open, Print etc., you can invoke them.

| improve this answer | |
1

In order to do this, the application must be designed to expose it's commands to external callers. Paint is not designed in this manner.

It might still be possible to interact with Paint via PowerShell using the Automation APIs available in .NET but I have not investigated this personally.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.