2

This should work fine in PowerShell older than 3. I need to run two processes: wuapp.exe and desk.cpl with ScreenSaver's tab. The problem I have is that once I start wuapp.exe the process name shows up in Task Manager as explorer.exe - the current code works for wuapp.exe but not on every machine. The other thing is when I kill rundll32 other apps will close also. What do you suggest?

$wshell = New-Object -ComObject Wscript.Shell
Start-Process  wuapp.exe
(New-Object -comObject Shell.Application).Windows() | foreach-object {$_.quit()}
Start-Process rundll32 desk.cpl,InstallScreenSaver
Stop-Process -ProcessName rundll32* -Force
ppiotrek
  • 55
  • 2
  • 2
  • 8

1 Answers1

10

I'm not entirely sure what you mean by wuapp.exe showing up as explorer.exe, but keeping track of the rundll32 process is fairly straightforward.

Use Start-Process with the PassThru parameter to have it return the process it creates:

$ScreenSaverCpl = Start-Process rundll32 desk.cpl,InstallScreenSaver -PassThru
# Call Stop-Process when no longer needed:
Stop-Process $ScreenSaverCpl
Mathias R. Jessen
  • 157,619
  • 12
  • 148
  • 206
  • The problem with wuapp.exe is that once I run it I see in Task Manager "Windows Update" but when I go to Processes it highlights explorer.exe and there is no such process as wuapp.exe. How can I track it? – ppiotrek Nov 25 '15 at 12:05