2

My work account is a non-admin but I have the admin password. I need to run a .bat file as admin automatically when windows starts from my non-admin account. I couldn't figure out how to feed in the admin password to make the .bat file run as admin. Any idea? Thanks. This is for Windows 7. Just to clarify, I can do these steps manually after login: 1. Run DOS command as admin 2. Enter admin credential 3. Run the script file. How can I run these 3 steps automatically and silently in the background?

2 Answers 2

0

Some people get around this by setting up a task in Task Scheduler. You reference the batch file and you use the Administrator credentials. You should test to see the first few times that it actually runs each login. Also, you will need to change the saved password if the Administrator password expires or changes.

3
  • I tried what you suggested but I was unable to create the task after I entered admin pw. The system wouldn't let me. I guess my non-admin account has very limited power.
    – avt
    Apr 16, 2015 at 0:53
  • Hold on, I think there is something you haven't said? Is this computer logged into a domain? e.g. is it a work computer? Apr 16, 2015 at 7:36
  • He said "my work account" in his initial post.
    – Sun
    Apr 16, 2015 at 15:40
0

You need to create a shortcut to the bat file. Then right-click and choose properties for the shortcut and you can change which account runs the shortcut and hence the batch file.

UPDATE: From the clarification, you want to run something at "startup" without giving an admin password. There are several possibilities depending on your actual need. Startup could mean machine startup or at login?

There are several ways to run programs at different times but the Task Scheduler is probably the easiest. This lets you schedule tasks for both boot time and login time not just on a clock-type schedule.

You will find task scheduler in Control Panel or search for it in start menu. The settings are fairly self-evident.

If your program needs specific rights to do something (you've not mentioned what), best to create a specific user with just those rights if you can so that there is less danger of compromising the whole machine if you get hacked. However, either way, the create task dialog allows you to run as any valid user and also allows you to store credentials in the Windows credential store so there is a modicum of security.

Add a trigger for either logon or startup as required. Add an action to run your batch file. Add any conditions where you might not want to run the action and then OK it all.

Just remember that, if you run at system startup, you will not have the same environment as when running locally, make sure your batch file only uses absolute paths & test it carefully.

You mention in another comment that you cannot create a scheduled task with your normal login. If this is the case, you need to log-in with the admin account to set up the schedule.

2
  • I checked the "Run As Administrators" in the Advanced menu but it only asked for admin password when I run the batch file which is not what I want. I want to somehow feed in the admin password in advance so it will run automatically at startup.
    – avt
    Apr 16, 2015 at 0:44
  • Ah, I see - actually I don't think that IS what you want to do. I'll update. Apr 16, 2015 at 7:10

You must log in to answer this question.

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