1

I have a batch file that I run to install a bunch of programs onto computers, is there any way in the properties to either set it as needing to be run as admin (so that it gives you the prompt) or that it exits immediately if not run as an admin?

It is a pain to accidentally run it not as admin and then have to reinstall each missed program individually (some programs don't require admin).

I've had a look in the properties of the batch file but can't seem to find the right menu.

Cjen1
  • 1,826
  • 3
  • 17
  • 47
  • 1
    take a look [here](http://stackoverflow.com/questions/4051883/batch-script-how-to-check-for-admin-rights) – npocmaka Sep 15 '16 at 10:52
  • you can also create a shortcut to a batch file that requests admin permissions.From command line you can use [shortcutjs.bat](https://github.com/npocmaka/batch.scripts/blob/master/hybrids/jscript/shortcutJS.bat) – npocmaka Sep 15 '16 at 10:54
  • Thanks that's works just how I wanted it to – Cjen1 Sep 15 '16 at 10:58
  • If you want to answer it go ahead @npocmaka otherwise just comment here if you think it should be closed and I'll just delete it – Cjen1 Sep 15 '16 at 10:58

1 Answers1

1

If you want to check if you have admin privileges check this.

If you want your batch to request admin privileges you'll need to create a shortcut . shortcutJS.bat can create a shortcut with "run as admin" thick from command line :

call shortcutJS.bat -linkfile "some.lnk" -target "%cd%\some.bat" -adminpermissions yes
Community
  • 1
  • 1
npocmaka
  • 55,367
  • 18
  • 148
  • 187