# I want a shortcut to toggle a service in Win10

**URL:** <https://forums.powershell.org/t/i-want-a-shortcut-to-toggle-a-service-in-win10/10230>\
**Category:** PowerShell Help\
**Created:** [March 2, 2018, 9:27am UTC](https://forums.powershell.org/t/i-want-a-shortcut-to-toggle-a-service-in-win10/10230 "2018-03-02T09:27:10Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![sebastian42](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@sebastian42](https://forums.powershell.org/u/sebastian42)\
**Post date:** [March 2, 2018, 9:27am UTC](https://forums.powershell.org/t/i-want-a-shortcut-to-toggle-a-service-in-win10/10230/1 "2018-03-02T09:27:10Z")

</div>

I’ve been told the code I should use and reproduce it below, but have NO idea how to apply it, so I need help.

"To stop a service run the following command:  
Stop-Service ServiceName  
To start a service run the following command:  
Start-Service ServiceName

You can add that code to separate .PS1 files, or use the PowerShell editor to create your scripts."

Since I have no idea about .PS1 files, but CAN launch the Powershell editor - the second option might suit me best.  
I can launch Powershell editor - but it evaporates after a few seconds.

---

<div class="post-metadata">

**Author:** ![donj](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/donj/32/137_2.png) [@donj](https://forums.powershell.org/u/donj)\
**Post date:** [March 2, 2018, 9:29am UTC](https://forums.powershell.org/t/i-want-a-shortcut-to-toggle-a-service-in-win10/10230/2 "2018-03-02T09:29:24Z")

</div>

It might be worth doing some basic learning on PowerShell first, but a .ps1 file is just a text file that PowerShell regards as an executable script. You fill it with commands you want to run, and it runs them in order.

I’m afraid I doin’t understand “evaporates” in terms of software, but any text editor will do.

If PowerShell’s going to be part of your life, I respectfully suggest you read “Learn Windows PowerShell in a Month of Lunches.” It’s a short, easy read, and it’ll get you very much not he right track with a lot less grief.

---

<div class="post-metadata">

**Author:** ![sebastian42](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@sebastian42](https://forums.powershell.org/u/sebastian42)\
**Post date:** [March 2, 2018, 10:13am UTC](https://forums.powershell.org/t/i-want-a-shortcut-to-toggle-a-service-in-win10/10230/3 "2018-03-02T10:13:29Z")

</div>

I have experience with TRYING to write Macros and VBscript - and while I had success, it was only because I got models to adapt my needs to. I found it VERY time consuming.

I infer from your hints that if I put  
“To stop a service run the following command:  
Stop-Service ServiceName  
To start a service run the following command:  
Start-Service ServiceName”  
into a text file and save it as PS1  
I have a script that Powershell can execute.

This is where we run into the ‘evaporates’ problem.  
After I launch Powershell, a DOS like window open for a few seconds, then closes - Powershell ‘evaporates’.  
I have no idea what is SUPPOSED to happen, but a disappeared window give me NO options to proceed.  
I hope you will take mercy on my predicament, and help me further.

I do NOT expect the Powershell is going to be ‘part of my life’, but since ‘using Powershell’ has been the only suggestion I got when asking for a shortcut to toggling ONE service, I did start reading the introduction to Powershell - that did NOT reduce my perplexity.

---

<div class="post-metadata">

**Author:** ![bobbyt](https://avatars.discourse-cdn.com/v4/letter/b/ccd318/32.png) [@bobbyt](https://forums.powershell.org/u/bobbyt)\
**Post date:** [March 2, 2018, 5:57pm UTC](https://forums.powershell.org/t/i-want-a-shortcut-to-toggle-a-service-in-win10/10230/4 "2018-03-02T17:57:22Z")

</div>

If you don’t see powershell as part of your life then maybe you would be better sticking with native windows commands. The Sc.exe command can start and stop a service for you, and no powershell is required.

---

<div class="post-metadata">

**Author:** ![sebastian42](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@sebastian42](https://forums.powershell.org/u/sebastian42)\
**Post date:** [March 3, 2018, 6:18pm UTC](https://forums.powershell.org/t/i-want-a-shortcut-to-toggle-a-service-in-win10/10230/5 "2018-03-03T18:18:23Z")

</div>

I am not fussy about the mechanism to achieve a single click toggle for one service. e.g. I would be happy with a macro or a batch file but I have never heard of an sc.exe command. If sc.exe can do what I want, I would much appreciate some detail about how to apply it.

---

<div class="post-metadata">

**Author:** ![bobbyt](https://avatars.discourse-cdn.com/v4/letter/b/ccd318/32.png) [@bobbyt](https://forums.powershell.org/u/bobbyt)\
**Post date:** [March 3, 2018, 7:13pm UTC](https://forums.powershell.org/t/i-want-a-shortcut-to-toggle-a-service-in-win10/10230/6 "2018-03-03T19:13:20Z")

</div>

> **[LMGTFY - Let Me Google That For You](https://lmgtfy.app/?iie=1&amp%3Bq=Sc.exe)**
>
> For all those people who find it more convenient to bother you with their question rather than to Google it for themselves.

---

<div class="post-metadata">

**Author:** ![sebastian42](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@sebastian42](https://forums.powershell.org/u/sebastian42)\
**Post date:** [March 3, 2018, 7:24pm UTC](https://forums.powershell.org/t/i-want-a-shortcut-to-toggle-a-service-in-win10/10230/7 "2018-03-03T19:24:28Z")

</div>

Well, at least I now know that sc means Service Control. The rest of that referred post is gobbledgook to me.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:36pm UTC](https://forums.powershell.org/t/i-want-a-shortcut-to-toggle-a-service-in-win10/10230/8 "2024-05-16T20:36:15Z")

</div>

Closed on May 16, 2024, 8:36pm UTC


