process - How do I open an image and then close it automatically in PowerShell? -


i want open image in windows photo viewer , close automatically using powershell. how achieve this?

i tried using start-process cmdlet open image default application , have return associated process id. image opened, don't process id. because windows photo viewer-process packed inside dllhost.exe.

ps c:\users\public\pictures> $process = start-process -filepath .\wiki-error.jpg -passthru start-process : command cannot run because system cannot find information required. @ line:1 char:12
+ $process = start-process -filepath .\wiki-error.jpg -passthru + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + categoryinfo : invalidoperation: (:) [start-process], invalidoperationexception + fullyqualifiederrorid : invalidoperationexception,microsoft.powershell.commands.startprocesscommand ps c:\users\public\pictures> $process.id
ps c:\users\public\pictures> stop-process $process.id
stop-process : cannot bind argument parameter 'id' because null. @ line:1 char:14 + stop-process $process.id + ~~~~~~~~~~~ + categoryinfo : invaliddata: (:) [stop-process], parameterbindingvalidationexception + fullyqualifiederrorid : parameterargumentvalidationerrornullnotallowed,microsoft.powershell.commands.stopprocess command

i run powershell 2.1 , windows 7. suggestions?


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -