{"id":711,"date":"2014-09-09T00:01:00","date_gmt":"2014-09-09T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2014\/09\/09\/use-powershell-to-provide-startup-information\/"},"modified":"2014-09-09T00:01:00","modified_gmt":"2014-09-09T00:01:00","slug":"use-powershell-to-provide-startup-information","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/use-powershell-to-provide-startup-information\/","title":{"rendered":"Use PowerShell to Provide Startup Information"},"content":{"rendered":"<p><b>Summary<\/b>: Microsoft Scripting Guy, Ed Wilson, talks about using Windows PowerShell to find startup information.<\/p>\n<p><img decoding=\"async\" alt=\"Hey, Scripting Guy! Question\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" \/>&nbsp;Hey, Scripting Guy! It seems that my laptop running Windows&nbsp;8.1 takes forever to start lately. I don&rsquo;t really even know where to begin with this. I haven&rsquo;t added anything that I know of, but still it is dog slow. I don&rsquo;t want to reinstall Windows because&hellip;well, for one thing, if I don&rsquo;t solve the issue, it might come back again. Can Windows PowerShell help me with this?<\/p>\n<p>&mdash;OB<\/p>\n<p><img decoding=\"async\" alt=\"Hey, Scripting Guy! Answer\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" \/>&nbsp;Hello OB,<\/p>\n<p>Microsoft Scripting Guy, Ed Wilson, is here. The weather is still a bit warm for my taste. I figure it will cool down soon, but when it is 85 degrees Fahrenheit (29.4 degrees Celsius) outside and it is only 7:00 in the morning, I do not think it is going to bode well for a balmy fall day.<\/p>\n<h2>The problem with startup in Windows<\/h2>\n<p>OB, I agree that there appears to be a problem with lots of stuff starting up. I have one laptop that, for whatever reason, literally takes five minutes before the drive calms down enough for me to be able to sign in. Then once I have signed in, it takes another five minutes before the laptop is usable. Granted, the laptop is five-years old, but dude, it was as fast as a machine could possibly be five years ago. It has 16&nbsp;GB of RAM, and that should be enough to run Windows, Outlook, and an occasional browsing activity. The issue is that it is way slow, so takes a while before I can do any of that.<\/p>\n<p>There are a number of places to find startup applications. Here are some of the more common locations:<\/p>\n<ul>\n<li>HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Run<\/li>\n<li>HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce<\/li>\n<li>HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run<\/li>\n<li>HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce<\/li>\n<li>HKU\\ProgID\\Software\\Microsoft\\Windows\\CurrentVersion\\Run<\/li>\n<li>systemdrive\\Documents and Settings\\All Users\\Start Menu\\Programs\\Startup<\/li>\n<li>systemdrive\\Documents and Settings\\username\\Start Menu\\Programs\\Startup<\/li>\n<\/ul>\n<p>On my laptop running Windows&nbsp;8.1, I can use the Task Manager, go to the Startup tab, and see a list of Startup applications. I can even disable startup applications here. This is shown in the following menu:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-9-9-14-01.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-9-9-14-01.png\" alt=\"Image of menu\" title=\"Image of menu\" \/><\/a><\/p>\n<p>The problem with only using the Startup tab from Task Manager is that it is per user. So if I create another user account, it will inherit all of the all user or public startup information. An example of this is the HKLM\\Run key mentioned earlier. It is shown here:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-9-9-14-02.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-9-9-14-02.png\" alt=\"Image of menu\" title=\"Image of menu\" \/><\/a><\/p>\n<p>That is a lot of stuff, and it is only one of the many locations to find startup applications. If I create a new user on the machine, I will immediately get a call asking me to come and figure out why Windows is taking forever to start. It is better to &ldquo;nip things in the bud&rdquo;&mdash;and to do that, I need information.<\/p>\n<h2>Use WMI<\/h2>\n<p>I can get the information I need by using WMI to find where things start and what is starting. The Win32_StartupCommand WMI class will help me here. Here is a quick script I wrote to find the information I need:<\/p>\n<p style=\"margin-left:30px\">Get-CimInstance Win32_StartupCommand |<\/p>\n<p style=\"margin-left:30px\">Select-Object Name, command, Location, User |<\/p>\n<p style=\"margin-left:30px\">Format-List&nbsp;<\/p>\n<p>The Win32_StartupCommand WMI class is documented on MSDN: <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/aa394464(v=vs.85).aspx\" target=\"_blank\">Win32_StartupCommand class.<\/a> I decided that the properties I need are the name of the command, the command itself, the location, and the user that it applies to. The best way to view this information is in a list due to the length of the command lines. That is it. Here is the script and a sample of the output.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-9-9-14-03.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-9-9-14-03.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>OB, that is all there is to using WMI to explore Windows startup information. WMI Week will continue tomorrow when I will talk about more cool Windows PowerShell and WMI stuff.<\/p>\n<p>I invite you to follow me on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\" target=\"_blank\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\" target=\"_blank\">Facebook<\/a>. If you have any questions, send email to me at <a href=\"mailto:scripter@microsoft.com\" target=\"_blank\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\" target=\"_blank\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.<\/p>\n<p><b>Ed Wilson, Microsoft Scripting Guy<\/b><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Microsoft Scripting Guy, Ed Wilson, talks about using Windows PowerShell to find startup information. &nbsp;Hey, Scripting Guy! It seems that my laptop running Windows&nbsp;8.1 takes forever to start lately. I don&rsquo;t really even know where to begin with this. I haven&rsquo;t added anything that I know of, but still it is dog slow. I [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[86,385,31,3,4,45,6],"class_list":["post-711","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-basic-information","tag-cim","tag-operating-system","tag-scripting-guy","tag-scripting-techniques","tag-windows-powershell","tag-wmi"],"acf":[],"blog_post_summary":"<p>Summary: Microsoft Scripting Guy, Ed Wilson, talks about using Windows PowerShell to find startup information. &nbsp;Hey, Scripting Guy! It seems that my laptop running Windows&nbsp;8.1 takes forever to start lately. I don&rsquo;t really even know where to begin with this. I haven&rsquo;t added anything that I know of, but still it is dog slow. I [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/711","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=711"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/711\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=711"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=711"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=711"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}