Scheduled powershell script requires keystroke input -
powershell script wont complete when running scheduled task. can run manually when scheduled task never completes, file isn't generated final move doesn't happen. suspect because keystrokes aren't being received can see exe process running in background , final keys strokes should exit app.
the exe runs not have arguments running silently need inject keystrokes.
$syncexe = "consoleserversync.exe" $syncfile = "sync_out.xml" $servdir = "c:\server\" $exportdir = "c:\export" if (test-path $servdir$syncfile) { remove-item $servdir$syncfile} if (test-path $exportdir$syncfile) { remove-item $exportdir$syncfile} start-process -filepath $servdir$syncexe start-sleep -s 10 add-type -assemblyname system.windows.forms [system.windows.forms.sendkeys]::sendwait("`r") [system.windows.forms.sendkeys]::sendwait("yes`r") [system.windows.forms.sendkeys]::sendwait("q`r") start-sleep -s 30 move-item $servdir$syncfile $exportdir
Comments
Post a Comment