Can I run a subst as admin when I startup?

4

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?

Jonny

Posted 2016-09-28T09:35:15.840

Reputation: 143

Answers

5

  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)

user631840

Posted 2016-09-28T09:35:15.840

Reputation: 66

3For the last step, I expect that logging out and logging in again is all you need to do. – Scott – 2017-11-08T22:37:27.813

1

Did you set up same subst for admin account startup? Then you can try make runas batch to run privileged copy of software with admin profile loaded.

meronbar

Posted 2016-09-28T09:35:15.840

Reputation: 11

Can you expand on that? I am asking how to do what you suggested. – Jonny – 2016-09-28T10:00:59.957

After testa little, i suggest something like that: When you need run something as other account, and with subst applied, create launcher.cmd with subst T: E:\Code\SourceControl c:\tools\sometools.exe
then runas /user:admin launcher.cmd
– meronbar – 2016-09-28T13:50:02.433