im looking but finding it but maybe u know it, is there a way to have it send the f5 key with powershell?
Yes and no. I tried sendkeys f5 (powershell console steals focus). I tried minimize console window, then refresh, didn't work. (explorer still had no focus), think it refreshed my 'taskbar'.
Then I tried this, but no go, focus. Explorer blinked but did not refresh fully, I think again focus issue.
http://powershell.com/cs/media/p/8322.aspx
Probably need to spawn powershell invisible so we don't lose focus in the first place. I've been using the old invisible.vbs or cmdow.exe but including those or nirsoft or below app would defeat the purpose.
http://www.ntwind.com/software/hstart.html
Note to self, remove the start /B (spawning powershell externally of cmd.exe) then add windowstyle -hidden and see if it won't run asynchronously and invisibly to cmd.exe. Maybe even a 1 second sleep to be sure the .cmd window has died.EDIT: windows style hidden still shows pop up.
This looks like the real way to invisible powershell.
http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo(v=vs.110).aspx
http://technet.microsoft.com/en-us/library/ff731006.aspx
Unless anyone can show me how to get the window title from explorer.exe pid so I could set focus properly.Code:$objStartInfo = New-Object System.Diagnostics.ProcessStartInfo $objStartInfo.FileName = "PowerShell.exe" $objStartInfo.windowStyle ="Hidden" $objStartInfo.arguments = "-noexit C:\Scripts\Test.ps1" [System.Diagnostics.Process]::Start($objStartInfo)
Last edited: