====== Windows Autostart Folder ====== Microsoft products have a folder which contains commands to be run for each user as they log in. Commands in these folders automatically run on login. Commands in the global startup directory run every time any user logs in. ===== Individual Startup ===== Each login has a customizable folder that will be run only when they log in. On Windows Server 2022, this folder is: C:\Users\USERNAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup where USERNAME is the name of the user you want to have the command. Any commands located in that folder are executed when user USERNAME user logs in. To avoid this folder being moved around in past/future versions of Windows, the shortcut //shell:startup// can be used, either by entering it in the the location bar of File Explorer, or by accessing the Run command (see below) - Click the "Start" button - Type //run// - Select the Run command - Enter //Shell:startup// in the Open box - Select Ok Windows File Explorer will open with the (usually empty) startup folder for the current user. ===== Global Startup ===== There is a global startup folder also, which is executed for any user when they log in. Again, in Server 2022, this is located in C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup, but and administrator can use the command //Shell:Common Startup// to locate this. ===== Use ===== ==== Convenience Shortcut Drive ==== We have a client on as Windows Terminal Server that was constantly frustrated saving files to a shared folder. In this case, it was Public Documents (c:\users\public\documents), so we created a "p" drive (for Public Drive) for them. This was created as a shortcut to the command C:\Windows\System32\subst.exe P: "C:\Users\Public\Documents" which we created as follows - Right click on desktop and select New | Shortcut - In "Location of the item", enter C:\Windows\System32\subst.exe P: "C:\Users\Public\Documents", then click Next - For Name, enter something like "Mount P Drive" and click Finish - Open File Explorer and enter Shell:Common Startup in the location bar - Drag the shortcut from your desktop to the folder which is opened. - The next time a user logs in, they will see Local Disk (P:) when they click on This PC (you may need a reboot first, I don't remember). ==== Running a program ==== Another need we found was to have NextCloud run as an individual user, even if no one was specifically logged into it. A common problem on a multi-user system like Windows Terminal Server, when multiple people share a common area (Public Documents) which need to be sync'd in real time. Windows allows us to automatically log in a user when the server starts up, but it would be a security breach if a user session was always available, so that user should automatically have their session locked after auto login. The procedure is documented in [[microsoft_windows:terminalserver:nextcloud]], but uses the //Shell:Startup// folder for that user.