3

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.

Gregory MOUSSAT
  • 832
  • 4
  • 13
  • 22

2 Answers2

4

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).

Emperor XLII
  • 13,014
  • 11
  • 65
  • 75
Baldwin D.
  • 110
  • 1
  • 6
  • 1
    Win8 and Win2012 users don't have startup folder until a program create it (or maybe it is preimaged/preinstalled. But with stock Windows, no startup folder). In this case, shell:startup leads to nowhere, and doesn't create the folder. – Gregory MOUSSAT Nov 23 '14 at 21:39
  • 1
    The command you gave works perfectly. Tested on Win8 and Win2012. When the startup folder is not present, it is created immediatly. Many thanks ! – Gregory MOUSSAT Nov 23 '14 at 21:48
2

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.

  • 1
    SHGetKnownFolderPath seems to be the right mean to do that. I try to use it from PowerShell but don't find how. I think I have to open a new question. – Gregory MOUSSAT Nov 23 '14 at 15:20