PowerShell Function to Restart a Process

My notebook connects to a Docking Station with access to my receiver with speakerset, 2 screens, power and a KVM switch for my mouse and keyboard. When I lock my laptop, the sounds switches from the receiver to my internal speakers. When I unlock my laptop, the sound switches back but the Spotify application doesn’t play any sound. Closing the application doesn’t solve this problem, because the application will crash and I have to use the Task Manager to force the application to close. I made a PowerShell function that I’ve added to my PowerShell profile.

The Restart-Spotify function looks for any process that ends with “spotify” and stops the process. When all the processes are killed, a new instance of Spotify will be opened and the PowerShell console will close itself.

Even a reinstall of Spotify doesn’t help solving this issue I’m facing for months now. So the above script is a great workaround for me.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s