It would probably be easier to use what Chris wrote (rather than my 
encodedcommand example) but start the command as a process so it runs in the 
background:

start-process powershell.exe -ArgumentList ' -NoExit -File 
c:\windows\temp\testfile.ps1' -WindowStyle Hidden

Use Get-Help and see options for Start-Process and for Powershell.exe to get 
all the switches/parameters available. If you want the script to exit when it 
completes do not use the –NoExit switch, that holds the session open. Kind of 
like the cmd /k (leave command window open after command terminates) switch.

From: [email protected] [mailto:[email protected]] On 
Behalf Of [email protected]
Sent: Thursday, January 23, 2014 5:03 PM
To: [email protected]
Subject: RE: [powershell] Any way of running a powershell script from a 
scheduled task, silently?

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File 
c:\scripts\Config_Fujitsu_hkcu_reg_keys.ps1 -WindowStyle Hidden

Christopher Catlett
Consultant | Detroit
[MCTS_2013_small]

Sogeti USA
Office 248-876-9738 |Fax 877.406.9647
26957 Northwestern Highway, Suite 130, Southfield, MI 48033-8456
www.us.sogeti.com<http://www.us.sogeti.com/>

From: [email protected] [mailto:[email protected]] On 
Behalf Of Daniel Ratliff
Sent: Thursday, January 23, 2014 4:42 PM
To: '[email protected]'; '[email protected]'
Subject: RE: [powershell] Any way of running a powershell script from a 
scheduled task, silently?

What's your current cmd?

-Daniel Ratliff

-----Original Message-----
From: 
[email protected]<mailto:[email protected]> 
[[email protected]<mailto:[email protected]>]
Sent: Thursday, January 23, 2014 03:34 PM Eastern Standard Time
To: [email protected]<mailto:[email protected]>
Subject: [powershell] Any way of running a powershell script from a scheduled 
task, silently?

I am running a script regularly to set some user settings, if it sees a 
particular piece of hardware present on the system.

I’ve tried the “–WindowStyle Hidden” and the “-NonInteractive” switches and 
they do not hide the powershell dialog.
A blank, blue window, is shown.

I’d really rather not have to wrap it inside a batch or vbscript.

This is a script running on Win8.1 machines, so v4 is available.

Christopher Catlett
Consultant | Detroit
[MCTS_2013_small]

Sogeti USA
Office 248-876-9738 |Fax 877.406.9647
26957 Northwestern Highway, Suite 130, Southfield, MI 48033-8456
www.us.sogeti.com<http://www.us.sogeti.com/>


================================================
Did you know you can also post and find answers on PowerShell in the forums?
http://www.myitforum.com/forums/default.asp?catApp=1
The information transmitted is intended only for the person or entity to which 
it is addressed
and may contain CONFIDENTIAL material. If you receive this material/information 
in error,
please contact the sender and delete or destroy the material/information.

================================================
Did you know you can also post and find answers on PowerShell in the forums?
http://www.myitforum.com/forums/default.asp?catApp=1

================================================
Did you know you can also post and find answers on PowerShell in the forums?
http://www.myitforum.com/forums/default.asp?catApp=1
**********************************************************
Electronic Mail is not secure, may not be read every day, and should not be 
used for urgent or sensitive issues 

================================================
Did you know you can also post and find answers on PowerShell in the forums?
http://www.myitforum.com/forums/default.asp?catApp=1

<<inline: image001.jpg>>

Reply via email to