Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3983468
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:39:06+00:00 2026-05-20T05:39:06+00:00

I would like to stop/kill a certain process and then start it again after

  • 0

I would like to stop/kill a certain process and then start it again after I am done doing what I have to do.

This is what I already have.

Clear-host
$processes = Get-Process devenv 
$processes.Count
if($processes.Count -gt 1)
{
    $i = 0
    Write-host "There are multiple processes for devenv."
    foreach($process in $processes)
    {
        $i++
        $i.ToString() + '. ' + $process.MainWindowTitle
    }
    $in = Read-host "Give a number of the process to kill: "
    write-host
    write-host "killing and restarting: " + $processes[$in-1].MainWindowTitle
    $processes[$in-1].Kill()
    $processes[$in-1].WaitForExit()
    $processes[$in-1].Start()

}
else
{
    write-host "something else"
}

But the Start needs some parameter which I thought I could get from the process. But I’m not really sure I know what to give it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T05:39:07+00:00Added an answer on May 20, 2026 at 5:39 am

    The $processes[$in-1].Start() will not work. You need to capture the processinfo you are killing and start the same app again. You can get the process binary and commandline information using Win32_Process WMI class.

    For example,

    Clear-host
    $processes = Get-Process notepad 
    $processes.Count
    if($processes.Count -gt 1)
    {
        $i = 0
        Write-host "There are multiple processes for notepad."
        foreach($process in $processes)
        {
            $i++
            $i.ToString() + '. ' + $process.MainWindowTitle
        }
        $in = Read-host "Give a number of the process to kill: "
        write-host
        write-host "killing and restarting: " + $processes[$in-1].MainWindowTitle
    
        #Get the process details
        $procID = $processes[$in-1].Id
        $cmdline = (Get-WMIObject Win32_Process -Filter "Handle=$procID").CommandLine
        $processes[$in-1].Kill()
        $processes[$in-1].WaitForExit()
    }
    

    In the above example, I am using WMI to get the commandline information for a process selected. If that were a notepad process with some open text file, the commandline for that process would look like "C:\WINDOWS\system32\NOTEPAD.EXE" C:\Users\ravikanth_chaganti\Desktop\debug.log

    Now, all you need to do is: Invoke that commandline somehow (this part is not there in example I wrote). A very blunt way to do that is:

    Start-Process -FilePath $cmdline.Split(' ')[0] -ArgumentList $cmdline.Split(' ')[1]
    

    But, in your case, there may not be any argument list.

    Hope this gives you an idea. Other PowerShell experts may have a different & efficient approach. This is just a quick hack.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to stop the execution of a process with Ctrl + C
I would like to stop images from loading, as in not even get a
and I would like to know if there is any way to stop a
I would like to have a reference for the pros and cons of using
I would like to have an iframe take as much vertical space as it
I have a service that I would like it to become single instance, because
I have a windows service written in C# .NET framework 3.5 and would like
I start the Windows On-Screen-Keyboard like that: s_onScreenKeyboard = new Process(); s_onScreenKeyboard.StartInfo = new
I would like to stop SNMP from starting with Windows (WinCE 6.0 x86). I
Is it possible to stop IIS7 from logging certain IP addresses? We have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.