1

I am not trying to do cheeky things, but my need is just to have two scripts for adding or removing IP routes using the following command in batch scripts:

Add route:

@echo off
route add -p 20.20.188.0 mask 255.255.255.0 192.168.122.254
exit

delete route:

@echo off
route delete 20.20.188.0
exit

My question is that now I cannot get it run just by double-click on the batch file. I always have to right click and choose: Run as Administrator option even my user is in the Administrator group.

Is there any way to introduce a command like sudo in Linux or anything else that can make me happy by just double-clicking on the file.

UPDATE:

I tried the runas solution here but as the answer state:

Note, however, that this is not exactly like sudo - you can't use it to elevate yourself, just run something as a different user. If you're already have administrative rights, a runas to your account will give you the same access as the regular command (unless, of course, you runas a different administrator account, which will grant those administrator's rights to the new shell).

It is not a solution for my problem.

10

3 Answers 3

2

Create a shortcut to such batch script and then

  • in context menu click Properties
  • under Shortcut click Advanced button
  • select Run as administrator
1
  • Ah it is funny to see the "run as administrator" is grayed out on the batch file but another option exist on the shortcut (and the same option is still greyed out on the shortcut). Thanlks anyway it is the simplest way I will use.
    – рüффп
    Feb 19, 2014 at 19:56
1

As you mentioned in your comments using runas as the same user will not elevate you. There is no method I know of built in to windows that will elevate an already running command prompt.

In the past I have used 3rd party tools like Elevate.exe which will do the job for you, you just use it like you would use runas, just add the elevate program to your PATH variable and you can just do

elevate route add -p 20.20.188.0 mask 255.255.255.0 192.168.122.254
1
  • Interesting to see alternative, but I'd prefer laika's answer as there's no third party software to install.
    – рüффп
    Dec 24, 2016 at 9:27
0

I use "eldo" and "eldoGUI" for this purpose (running batch files elevated). They are available here, although I have absolutely no idea who created them in the first place.

Call eldoGUI like this:

Z:\eldoGUI.exe Z:\Backup-Music.cmd

This will produce the usual UAC prompt and proceed to run the command.

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