Stop Processes Excluding The Ones From The File

Copper Contributor

Hi,

 

I came up with an idea to create a script that can possibly help speed up the PC quickly without having to restart it. Here is the idea:

1. Get all processes after the PC starts freshly

     Get-Process | Out-File -Path 'C:\processes.txt'

2. Then after some time when there are unnecessary processes running, I need to get rid of them, except those that are in the file. It would be kind of equal to restart of the PC without restarting.

 

Questions:
1. How to retrieve the processes from the file? The ones that are there would be excluded from stopping.
2. Is it better to use .txt or .csv for this purpose and why?

1 Reply
Get-Content or Import-Csv to import the data.

If you are just going to save the names of the processes to a file then either would work.