Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Don't show powershell in taskbar

152 views
Skip to first unread message

Staples

unread,
Dec 10, 2009, 7:21:01 AM12/10/09
to
I am running a powershell script through SCCM and it is appearing in the
taskbar.

Does anyone know how to hide the powershell windows from the displaying in
the taskbar?

command I am executing:
powershell -NoProfile -Noninteractive -command ".\installer.ps1
installer.xml;exit $LASTEXITCODE"

Robert Robelo

unread,
Dec 10, 2009, 12:26:30 PM12/10/09
to
PowerShell v2 has a WindowStyle parameter:

-WindowStyle
Sets the window style to Normal, Minimized, Maximized or Hidden.

--
Robert

Robert Robelo

unread,
Dec 10, 2009, 12:39:01 PM12/10/09
to

James R. Gentile

unread,
Dec 17, 2009, 2:55:37 PM12/17/09
to
Here's a script, call with the .ps1 you want to run hidden as argument[0]:

if ($args.count -ne 1) {write-host "Requires 1 Argument, exiting...";sleep
2; break}
$a = (get-item -ea silentlycontinue $args[0]).fullname
if ($a -eq $null) {write-host "$($args[0]) is not a valid location,
exiting...";sleep 2;break}


# Specifies a set of values that are used when you start a process.
$si = new-object System.Diagnostics.ProcessStartInfo
$si.fileName = "powershell.exe"
$si.Arguments= "-nologo -command `"$($a)`""
$si.WorkingDirectory = $pwd
# this will launch the process in the background (hidden)
$si.windowStyle = [System.Diagnostics.ProcessWindowStyle]::Hidden
# run process under alternate credentials
# $si.UserName="username"
# $si.Password="Password"

# start the process
$process = New-Object System.Diagnostics.Process
$process.startInfo=$si

# this is also valid
# $process = [System.Diagnostics.Process]::Start($si)

# close notepad and watch the output
#if($process.start()) { $process.waitForExit(); "existed"}

$process.start()

0 new messages