SEARCH

The How-To Geek Forums Have Migrated to Discourse

How-To Geek Forums / Windows 7

(Solved) - Make a batch file to run cmd as administrator

(14 posts)
  • Started 2 years ago by mohitjain
  • Latest reply from mohitjain
  • Topic Viewed 110723 times

mohitjain
mohitjain
Posts: 51

In window 7 and vista, i want to make a batch file that run command as administrator, help me...?

Posted 2 years ago
Top
 
ElmerBeFuddled
ElmerBeFuddled
Posts: 127

I don't think it is actually possible.

I am hoping to be proven wrong though!! :D

Posted 2 years ago
Top
 
ispalten
ispalten
Posts: 6259

Well, check here, ON HOW TO DO THIS. This will open a COMMAND prompt that is running as Administrator and will run all the BAT file commands as an Administrator.

I think you can do the SAME thing by putting a link/shortcut (icon) for BAT file on your desktop and then Right Mouse Button on the icon and selecting RUN AS ADMINISTRATOR.

Irv S.

Posted 2 years ago
Top
 
zs474
zs474
Posts: 887

if you make the .bat into a .exe with this tool, then you can make it run as admin.

BTW why not use VB Script ?

Posted 2 years ago
Top
 
Xhi
Xhi
Posts: 6298

Then there is also Create Administrator Mode Shortcuts Without UAC Prompts in Windows 7 or Vista if that is what you mean.

Posted 2 years ago
Top
 
UltimatePSV
UltimatePSV
Posts: 67

What I did was this:
1. Make a shortcut pointed to the command prompt (I named it Administrative Command Prompt)
2. Open the shortcut's properties and go to the Compatibility tab
3. Under the Privilege Level section, make sure the checkbox next to "Run this program as an administrator" is checked

Posted 2 years ago
Top
 
ElmerBeFuddled
ElmerBeFuddled
Posts: 127

But as I'm reading it, the op wants to click a batch file and it will run in cmd prompt in administrator mode. Apart from physically opening cmd prompt in Admin mode and entering the bat file name, I don't think that it is possible.

Well, after zs474's answer, there is a way, but not through normal methods.

Posted 2 years ago
Top
 
Xhi
Xhi
Posts: 6298

Make a batch file in an editor and nameit.bat then create a shortcut to it. Nameit.bat - shortcut. then right click on Nameit.bat - shortcut ->Properties->Shortcut tab -> Advanced and click Run as administrator. Execute it from the shortcut.

Accepted Answer · Posted 2 years ago
Top
 
ElmerBeFuddled
ElmerBeFuddled
Posts: 127

Cheers Xhi, So bloody easy when explained!!

Posted 2 years ago
Top
 
ispalten
ispalten
Posts: 6259

@Xhi, you try that? On my W7 x64 doing so has the choice grayed out?

Irv S.

Posted 2 years ago
Top
 
Xhi
Xhi
Posts: 6298

yes, I tried it before i posted it.

Posted 2 years ago
Top
 
raphoenix
raphoenix
Posts: 14920

It will be grayed out if one is running as Built in Administrator and gives themselves all privileges plus special permissions, ownerships, etc., etc..

That's what I do to keep the annoyances away. (lol) :) :)

EDIT: I do NOT recommend this method of Windows 7 operation.

Rick P.

Posted 2 years ago
Top
 
ronniesonora
Posts: 919

Try using "runas /user:administrator C:\data\mybatchfile.bat"

Posted 2 years ago
Top
 
mohitjain
mohitjain
Posts: 51

Thanks Xhi thats so cool tip it works as i want...thanks a lot..:)

Posted 2 years ago
Top
 



Topic Closed

This topic has been closed to new replies.