Create startup folder - Windows

2.5k views Asked by At

I script a lot of things to manage the computers in my company. I often need to add shortcuts into the personnal startup folder of users (without a GPO).

Windows 8/8.1 doesn't have a personnal startup folder by default.
Its location is C:\Users\<username>\AppData\Roaming\Microsoft\Windows\Start Menu\

It is easy to create this folder, but it needs a desktop.ini file into it, with the correct content, for the name to be localised (else it is displayed "Startup" whatever the language).

What is the "official" way to create this folder?
Or what is the official way to add something into it?
I'd prefer a PowerShell or batch command, but whatever reliable mean is okay.

2

There are 2 answers

2
Baldwin D. On BEST ANSWER

I guess you can do something with the ComObject for this special folder:

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

By the way, if I enter shell:startup in a run 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).

1
Bernad MAVISSU On

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 neve created. And I don't know any API entry to create it.

So you have to manually create it:

  1. check if the former command return anything (if yes, just create you shortcut)
  2. create yourself the startup folder. Use [environment]::getfolderpath("StartMenu") and add \startup to the path
  3. then create the desktop.ini file and populate it yourself
  4. and update the registry HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders (I didn't check if this is the right place. [environment]::getfolderpath("Startup") must return the right value)

UPDATE: I just found SHGetKnownFolderPath API which allow to create the required folder if needed (with dwFlags). I'm not good at PowerShell, so I don't know how to call this. Maybe Someone can give a better answer.