PowerShell code line syntax for set service start up type option Automatic (Delayed Start)

User avatar
DocAElstein
4StarLounger
Posts: 545
Joined: 18 Jan 2022, 15:59
Location: Re-routing rivers, in Hof, Beautiful Bavaria

PowerShell code line syntax for set service start up type option Automatic (Delayed Start)

Post by DocAElstein »

Hi
This is related to this Thread a bit
https://eileenslounge.com/viewtopic.php ... 53#p291953

I am using ____ coding in PowerShell to set a service. The service has 4 start up type options
Automatic (Delayed Start)
Automatic
Manual
Disabled

I can get three of them using any amount of the appropriate word in upper or lower case.
For example in PowerShell with administrator rights, all these do what I want
Set-Service "dmwappushservice" -StartupType Disabled # sets Disabled( or Deaktiviert )
Set-Service "dmwappushservice" -StartupType dis # sets Disabled( or Deaktiviert )
Set-Service "dmwappushservice" -StartupType man # sets Manual( or Manuell )
Set-Service "dmwappushservice" -StartupType Auto # sets Automatic( or Automatisch )
Set-Service "dmwappushservice" -StartupType au # sets Automatic( or Automatisch )


Etc.




But I can’t yet get the syntax for Automatic (Delayed Start)

Anyone got any idea or suggestions.

Thanks
Alan
You do not have the required permissions to view the files attached to this post.
I seriously don’t ever try to annoy. Maybe I am just the kid that missed being told about the King’s new magic suit, :(

User avatar
John Gray
PlatinumLounger
Posts: 5401
Joined: 24 Jan 2010, 08:33
Location: A cathedral city in England

Re: PowerShell code line syntax for set service start up type option Automatic (Delayed Start)

Post by John Gray »

Does the perusal of the Command Prompt SC.exe documentation assist in any way?
John Gray

Venison is quiet deer, and quite dear.

User avatar
DocAElstein
4StarLounger
Posts: 545
Joined: 18 Jan 2022, 15:59
Location: Re-routing rivers, in Hof, Beautiful Bavaria

Re: PowerShell code line syntax for set service start up type option Automatic (Delayed Start)

Post by DocAElstein »

Hi John,
Thx for the reply.
That doesn’t directly help me, as its way, way too heavy for me. I only just started with doing anything with these command things. Maybe someone else might be able to do something with it though to assist me, or if not , when I am better clued up on these things I might be able to use it to solve the problem later with it if no one else can help me in the meantime. So thanks anyway
Alan

P.S. It looks like one of my Most Beautiful long single line VBA code lines, Lol :)
( It took me a few years to get that far in VBA.... )
I seriously don’t ever try to annoy. Maybe I am just the kid that missed being told about the King’s new magic suit, :(

User avatar
Jay Freedman
Microsoft MVP
Posts: 1312
Joined: 24 May 2013, 15:33
Location: Warminster, PA

Re: PowerShell code line syntax for set service start up type option Automatic (Delayed Start)

Post by Jay Freedman »

I tried the value shown in the list for the start parameter in the documentation that John linked to, delayed-auto, but PowerShell didn't like that either. Here's the error message it showed in English:
1.png
Apparently there is no enumeration value in the ServiceStartMode type that corresponds to delayed-auto.
You do not have the required permissions to view the files attached to this post.

User avatar
DocAElstein
4StarLounger
Posts: 545
Joined: 18 Jan 2022, 15:59
Location: Re-routing rivers, in Hof, Beautiful Bavaria

Re: PowerShell code line syntax for set service start up type option Automatic (Delayed Start)

Post by DocAElstein »

Hi Jay,
I just tried as well, no joy either
Doesn't like delayed-auto either.JPG

(But always good to see it in English as well, thanks, and thanks for trying)

I thought I read somewhere something about that this option was added "later", so maybe it "missed the boat" in getting added to the available PowerShell syntax options
You do not have the required permissions to view the files attached to this post.
I seriously don’t ever try to annoy. Maybe I am just the kid that missed being told about the King’s new magic suit, :(

JoeP
SilverLounger
Posts: 2048
Joined: 25 Jan 2010, 02:12

Re: PowerShell code line syntax for set service start up type option Automatic (Delayed Start)

Post by JoeP »

I was able to use the Set_Service command to change the startup type from Manual to AutomaticDelayedStart and then back to Manual.

This is using PowerShell 7.2.1 on a Windows 11 Pro machine. Running PS as Administrator.

I get the same error when I use the built-in Windows PowerShell.
Joe

User avatar
DocAElstein
4StarLounger
Posts: 545
Joined: 18 Jan 2022, 15:59
Location: Re-routing rivers, in Hof, Beautiful Bavaria

Re: PowerShell code line syntax for set service start up type option Automatic (Delayed Start)

Post by DocAElstein »

Thanks, that’s good to know. It perhaps supports the idea that it was added later as an option so the syntax is missing from some older things.
I think I mostly have powershell 5.1, but have not checked all my machines, just now one is slowly updating itself to the newest Windows 10, (has been all day, lol), so I will check again on that tomorrow.
I will remember to check again if/ when I get a windows 11 machine in a few weeks.
I seriously don’t ever try to annoy. Maybe I am just the kid that missed being told about the King’s new magic suit, :(

User avatar
HansV
Administrator
Posts: 78233
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: PowerShell code line syntax for set service start up type option Automatic (Delayed Start)

Post by HansV »

PowerShell 7.2 requires Windows 10 (version 1607 or later) or Windows 11.
PowerShell 7.0 and 7.1 also run in Windows 8.1.
Best wishes,
Hans

JoeP
SilverLounger
Posts: 2048
Joined: 25 Jan 2010, 02:12

Re: PowerShell code line syntax for set service start up type option Automatic (Delayed Start)

Post by JoeP »

PowerShell 7.0 and above is a separate install from the built-in PowerShell. PS7 runs side by side with the built-in version. PS7 is a new, cross-platform, open-source version. See PoweShell for in-depth documentation plus an extensive gallery of PS code.
Joe

User avatar
DocAElstein
4StarLounger
Posts: 545
Joined: 18 Jan 2022, 15:59
Location: Re-routing rivers, in Hof, Beautiful Bavaria

Re: PowerShell code line syntax for set service start up type option Automatic (Delayed Start)

Post by DocAElstein »

Thx Hans, Thx Joe for the replies
I will look into PS7
I might wait until I have windows 11 and check out Terminal stuff at the same time.
For now, as I know from you the syntax that might work in newer stuff, I will leave the coding I have perhaps like this

Set-Service "dmwappushservice" -StartupType Automatic
Set-Service "dmwappushservice" -StartupType AutomaticDelayedStart


The coding I have has some sort of error handling I think , which I don’t understand yet, but it seems to ignore errors, so I assume those two line will give me Automatic (Delayed Start) if it can, otherwise make it Automatic.
( I assume Automatic is the next best thing, but that is a very uneducated guess? – Basically I have a coding that is supposed to tidy up / debloat / speed up windows 10. Mostly I have seen that virgin versions have Automatic (Delayed Start)
The coding changes that to Manual. - People smarter than me think either that or Disabled is a good idea
The coding has an undo/ restore section which is intended to put things back as they were. The coding had a few typos and simple careless mistakes, one of which was that the service "dmwappushservice" had been missed out of the undo section. As per Sod’s Law, it was the only changed Service that originally had Automatic (Delayed Start) )
Last edited by DocAElstein on 25 Jan 2022, 15:55, edited 1 time in total.
I seriously don’t ever try to annoy. Maybe I am just the kid that missed being told about the King’s new magic suit, :(

JoeP
SilverLounger
Posts: 2048
Joined: 25 Jan 2010, 02:12

Re: PowerShell code line syntax for set service start up type option Automatic (Delayed Start)

Post by JoeP »

There are some differences between Windows PS and PS7. See PowerShell differences for more details.

I believe that going forward PS7 is where Microsoft will devote its resources.
Joe