End Process in Powershell with absolutely no output

Viewed 150

I have a script which does some settings in registry. As a consequence I have to kill one process.

Stop-Process -processname explorer -force | Out-Null 

Now I would like to get rid of this message:

Der Vorgang wurde erfolgreich beendet.

(I guess english version must be something like: The process was completed successfully) Do you have any idea how to stop all output of Stop-Process?

#Update You are very right I should have tried just that command alone to see it is not the right command to look at. I structured my console output better to find out what command is causing me that trouble and found out these two:

reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v Wallpaper /t REG_SZ /d C:\folder\wallpaper.png /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Power" /v HiberbootEnabled /t reg_dword /d 0 /f

Append these two with | Out-Null works just as expected. :)

I guess I was confused by the message "The process was completed successfully" because I would not expect it after editing registry. In my script I use also other methods to change registry and they do not produce that output. For example:

Set-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\Explorer" -Name "DisableNotificationCenter" -Type DWord -Value 1

And since I had this message appear two times and I was killing two processes in my script I was wrong assuming that Stop-Process is at fault. Yet another example how easy it is to draw wrong correlations. Thanks for Help. I can't grasp how could I miss it.

1 Answers

Are you sure that you are trying to suppress the right thing? This is a typical message of reg command, which is probably used in your script considering it does some settings in the registry. Out-Null that instead of Stop-Process.

Related