Garacesh Posted November 24, 2014 Posted November 24, 2014 (edited) Trying to set up a proof-of-concept machine for print release. Have a powershell script set up to check for the print release client and on-screen keyboard. It runs as a scheduled task ever minute. if (($(Get-Process).ProcessName) -notcontains "Release-Software") { if (($(Get-Process).ProcessName) -contains "osk") { Stop-Process -Name "osk" -Force } Start-Process "\\PrintServer\Release-Software" Start-Sleep -Seconds 15 } if (($(Get-Process).ProcessName) -notcontains "osk") { Set-ItemProperty -Path "HKCU:\Software\Microsoft\Osk" -Name "Dock" -Value "1" Start-Sleep -Seconds 3 Start-Process osk } That runs fine. Problem is, setting the scheduled task for "powershell.exe \\PrintServer\Script.ps1" works as intended, but brings up a powershell console. I wouldn't even mind if it was brought up behind the current windows, but it doesn't. It's on-top, taking focus. Tried using a VBScript found online to silently launch the powershell script but even that still brings up the TaskEng.exe box for a moment. Using the 'Hidden' flag when setting up the task does nothing. Anyone know of a way to do this? A box popping up every minute would only freak out and confuse our users. Edited November 24, 2014 by Garacesh
Mustang Posted November 24, 2014 Posted November 24, 2014 PowerShell.exe -windowstyle hidden \\PrintServer\Script.ps1
Garacesh Posted November 26, 2014 Author Posted November 26, 2014 PowerShell.exe -windowstyle hidden \\PrintServer\Script.ps1 Tried that. Still brings up the 'Windows Powershell' box for ~1s. Not a massive issue but it appears on-top, and that'll confuse staff as it runs every minute to make sure the print release software is running.
Garacesh Posted November 26, 2014 Author Posted November 26, 2014 Aaaaaaaghhhhhh Managed to get the VBScript working so that it runs silently. Dim shell,command command = "powershell.exe -nologo -command \\PrintServer\PrintRelease.ps1" set shell = CreateObject("WScript.Shell") shell.Run command,0 And that runs silently if I point the scheduled task straight to the .VBS (rather than using cscript to run it).. But now it keeps coming up with "How do you want to open this type of file (.vbs)?" every minute when it tries to run! D:
Arthur Posted November 26, 2014 Posted November 26, 2014 (edited) Try this (without the VBS)... PowerShell.exe -NoProfile -NoLogo -NonInteractive -WindowStyle Hidden -ExecutionPolicy Bypass -File '\\PrintServer\PrintRelease.ps1' Edited November 26, 2014 by Arthur
Garacesh Posted November 26, 2014 Author Posted November 26, 2014 Nada.. I've tried most of those parameters individually and they didn't work.. Trying them together yields the same result However.. Calling the VBS with wscript instead of cscript makes it work. Hooway! \o/
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now