Windows – run a subst as admin when I startup

administratorbootsubstwindows

I have a subst command in my startup folder. It adds my Visual Studio projects to a different drive so that it is easier to access, and also so that the path doesn't get too long.

Occasionally I need to use the elevated privileges on something in that virtual drive (e.g. attach to w3wp.exe). It seems that the subst command is not carried over to the elevated privileges and I often get "folder does not exist" type errors.

What I have:

subst T: E:\Code\SourceControl

What I want (clearly sudo doesn't work on windows, but you get the idea):

subst T: E:\Code\SourceControl
sudo subst T: E:\Code\SourceControl 

tl;dr:
Is there a way to make the subst run for the admin account at the same time as the main account at startup?

Best Answer

  1. Run Task Scheduler as administrator
  2. Right click on Task Scheduler Library, choose “Create Task...”
  3. Under “General” tab, check “Run with highest privileges”
  4. Under “Triggers” tab, add “At log on” trigger
  5. Under “Actions”, put the parameters: Action = “Start a program”, Program/script = subst, Add arguments (optional) = T: E:\Code\SourceControl
  6. Under “Conditions”, uncheck “Start the task only if the computer is on AC power”
  7. Click “OK” to save the new task
  8. Log off and log on back again (or restart the computer)
Related Question