3

Using launchd on OS X, I can make commands/programs run at boot with launchctl in the CLI, so for example:
launchctl submit -l someName touch /usr/local/someFile
Would create someFile in /usr/local when booting.

How can I achieve this on Windows? What can I do in the cmd to make Windows run certain commands when booting?

I would like to run some command when a certain user logs in.

2
  • What exactly are you trying to do? Run a program during startup? Before a user login? During a user login?
    – DavidPostill
    Aug 22, 2015 at 19:57
  • @DavidPostill Preferably run some command when a certain user logs in.
    – Zocker3333
    Aug 22, 2015 at 20:47

2 Answers 2

5

How do I run some command when a certain user logs in?

You can use the Task Scheduler to create a task that is triggered by a Kernel-Power log event that indicates "Sleep":

  1. Run "Task Scheduler".
  2. Select "Task Scheduler Library
  3. Click menu "Action" > "Create Task"
  4. Select "General" and give the task a "Name" and Description"
  5. Select "Triggers" and click "New"

    • Set "Begin the Task" to "At log on"
    • Select "Specific user"
    • Press "Change User" and choose your "certain user"
    • Click "OK"

    enter image description here

  6. Select "Actions" and click "New"

    • Set "Program/script" to a script of your choice
    • Click "OK"

    enter image description here

2
  • Is there a way to do exactly this with a CLI instead of the UI?
    – Zocker3333
    Aug 23, 2015 at 9:39
  • @Zocker3333 Link?
    – coolaj86
    Jul 28, 2018 at 7:00
2

Windows has a multitude of places where applications or commands can run on startup.

There's folders, registry entries etc. there are so many places that msconfig has a Startup tab to try to show you some of them in one place.

You mention in the comment you want to have something start when a certain user logs in... and to save messing around with the registry then I would suggest creating a shortcut in the path:

C:\Users\<<Username>>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

This will vary depending on what version of Windows you are using. The folder you are looking for is the "startup folder" though for that user irrespective of Windows version.

If you wanted to do this from the command line then you could pipe your command into a batch file for instance or even use the Windows registry command line tools to add an entry to the registry's "Hive Key Current User" (HKCU) under HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run\

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .