Create Startup Folder - Windows

I script a lot of things to manage computers in my company. I often find myself adding shortcuts to a custom user startup folder (no GPO).

Windows 8 / 8.1 does not have a personal startup folder by default.
Its locationC:\Users\<username>\AppData\Roaming\Microsoft\Windows\Start Menu\

It's easy to create this folder, but it needs a file desktop.ini

with the correct content to localize the name (otherwise it will display "Launch" regardless of the language).

What is the "official" way to create this folder?
Or what's the official way to add something to it?
I would have preferred a PowerShell command or a batch command, but whichever reliable tool is okay.

+3


source to share


2 answers


I think you can do something with ComObject

for this special folder:

$startup = (New-Object -ComObject Shell.Application).NameSpace(0x07)

      



By the way, if I type shell:startup

in the startup box ( Win+ R) on my Win 8.1 system, it directs me to my personal startup folder ( C:\Users\User\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

).

+4


source


As far as I know, there is no reliable way to do this.

You can get the path with [environment]::getfolderpath("Startup")

, but the returned string is empty if the folder was created by neve. And I don't know of any API entry for creating it.

So, you have to manually create it:



  • check if the former command returns anything (if so, just create a shortcut)
  • create yourself a startup folder. Use [environment]::getfolderpath("StartMenu")

    and add \startup

    to path
  • then create desktop.ini file and write it yourself
  • and update the registry HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders

    (I didn't check if this location is [environment]::getfolderpath("Startup")

    correct . should return the correct value)

UPDATE: I just found the SHGetKnownFolderPath API that lets you create the folder you want (with dwFlags) if needed. I'm not very good at PowerShell, so I don't know what to call it. Perhaps someone can provide a better answer.

+2


source







All Articles