1

I have a script which I have to run frequently, but the exact moment is user-driven so I cannot use a scheduled task etc.

This script has to run with Admin-privileges (my account already has admin rights) so I cannot simply launch the script. Is there anye way to "self-elevate" this script?

very simple example:

ECHO "I would like to have admin rights to recycle the app-pool"
pause
DavidPostill
  • 7,734
  • 9
  • 41
  • 60
Christian Sauer
  • 10,351
  • 10
  • 53
  • 85
  • 2
    possible duplicate of [PowerShell: Running a command as Administrator](http://stackoverflow.com/questions/7690994/powershell-running-a-command-as-administrator) – MBu Jan 23 '15 at 08:29
  • Scheduled tasks can be triggered manually as well. Also, note that "run as administrator" requires that the user running the script either is a member of the administrators group, or has the credentials of an account that is. If you need to enable users to run something with elevated privileges *without* the users having actual admin access, scheduled tasks are your best bet. – Ansgar Wiechers Jan 23 '15 at 09:08
  • possible duplicate of [Self-Elevating Batch file (non-Admin user)](http://stackoverflow.com/questions/27956053/self-elevating-batch-file-non-admin-user) – MichaelS Jan 23 '15 at 11:39

1 Answers1

0

There is no way of self-elevation. But you are quite close to the solution. Create a task with the scheduler and then trigger it with another bat file like this:

SCHTASKS /U "user name" /P "password" /TN "Yourtaskname"

Or you can give a normal user the rights to run a task and skip /U "user name" /P "password".

MichaelS
  • 5,941
  • 6
  • 31
  • 46