Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Invoke Command = Press Enter on an EXE

$
0
0

Hi there

I'm calling an exe via powershell using the Invoke command and i seem to get error one machine and not the other. The only difference i can see is the Program Files path

This works

Invoke-command -computername $server -ScriptBlock `

               { write-host "Server : $env:computername" 

   & "C:\Program Files\APPS\Desk Move Watch Service\DeskMoveWatchService.exe"

$wshell = New-Object -ComObject wscript.shell;

$wshell.AppActivate('Apps.Systems.DeskMoveWatchService')

Sleep 1

$wshell.SendKeys('~')

} -credential $cred -erroraction 'stop' 

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

But this doesn't

Invoke-command -computername $server -ScriptBlock `

               { write-host "Server : $env:computername" 

   & "C:\Program Files (x86)\APPS\Desk Move Watch Service\DeskMoveWatchService.exe"

$wshell = New-Object -ComObject wscript.shell;

$wshell.AppActivate('Apps.Systems.DeskMoveWatchService')

Sleep 1

$wshell.SendKeys('~')

} -credential $cred -erroraction 'stop' 

 

Please could anyone share some advise


Viewing all articles
Browse latest Browse all 6937

Trending Articles