How to close window press Process Start in c#automation?

Asked

Viewed 18 times

0

Hello I am doing an automation and for that I needed to open the Power Options window in windows. For this I used the method:

Process.Start("Rundll32.exe", "shell32.dll,Control_RunDLL powercfg.cpl");

Now that I have finished automating I need to close this window. I have tried several combinations of KillProcess(); but none worked.

Can someone please give a hint?

  • I checked that the open Process was closed and that the window in Power Options was left with a different id under the name "explorer.exe" in the task manager. The "solution" found was to list all explorer processes and make a foreach killing everyone. If someone has a more elegant solution I accept it from the heart.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.