# Run Batch File As Administrator



## dannyn (Nov 9, 2007)

Hello,

How could I run a batch file as an administrator without any user involvement. I just want when the file is clicked on to start running as an admin because it is copying files in the Programs directory and cannot do it without administrator privileges. 

I have this... runas /noprofile /useran-Slate\Dan cmd but that requires me to have to type my password, and also just opens up a new shell and does not actually elevate the shell that it ran in. 

Any help would greatly be appreciated. Thank You!


----------



## Samsung (Nov 14, 2002)

right click it and choose run as Admin about best you can do. Create shortcut to it and you can right click choose properties cklick advanced button and tick the box Run as admin.Ok, Apply


----------



## dannyn (Nov 9, 2007)

That will not work. I mean I have got as far as the run as and that works, but if the account is password protected then they have to type a password. It must have no user interaction. It needs to be such that if I know the user name and computer or whatever details it may be(id prefer not to have to know even that) when writing the batch script I could put it on there computer and they could run it. Thanks for your prompt reply, but it wont work for me.


----------



## Samsung (Nov 14, 2002)

I'm having this difficulty also right now. I created a right click menu to run Dism commands for mounting .wim files and works fine with UAC off.

Dism.exe in system32 folder the Administrators have read and execute but I need to elevate the cmd /k
I wouldn't mind even finding a way to Invoke the uac prompt to come up.


----------



## Squashman (Apr 4, 2003)

You could try an encrypted runas program. There are free and paid versions out there. This might solve your issue.


----------



## Samsung (Nov 14, 2002)

I've looked at Elevate.vbs and .exe but I don't want to do that here. I've tried in registry shell\Runas also. There must be a way and I'll keep digging.


----------



## Squashman (Apr 4, 2003)

Samsung said:


> I've looked at Elevate.vbs and .exe but I don't want to do that here. I've tried in registry shell\Runas also. There must be a way and I'll keep digging.


Wasn't referring to those. Take a look at these.

http://www.snapfiles.com/get/runasspc.html
http://www.steelsonic.com/steelrunas.htm


----------



## Samsung (Nov 14, 2002)

neither, I am doing this from registry and don't want an app
http://www.msfn.org/board/topic/150275-add-right-click-wim-windows-7/
i can do this with setacl with my testing but looking for an app less method


----------



## Squashman (Apr 4, 2003)

Suit yourself. I am pretty sure we have covered this topic before on the forums. You may want to search for it.


----------



## Samsung (Nov 14, 2002)

Squashman said:


> Suit yourself. I am pretty sure we have covered this topic before on the forums. You may want to search for it.


I have searched these forums and many a Google link.
So instead I kept experimenting and now have solved what I wanted to do on my own. G


----------



## Squashman (Apr 4, 2003)

Samsung said:


> I have searched these forums and many a Google link.
> So instead I kept experimenting and now have solved what I wanted to do on my own. G


What is keeping you from posting your solution?


----------



## Samsung (Nov 14, 2002)

It is not the answer to this post I am doing opposite to what OP wanted. I wanted to raise the UAC prompt when I right click a .wim file and do something with it.

But here it is. To enable running certain exe in system32 under the UAC we have to tell it to run as Admin so it will raise the UAC prompt. These do not have advanced options so you can set the box. This in no way makes your sytem unsecure because it still asks if you want to do this.
Also remember there are 2 sides to the registry if you are running 64-bit

The way I done it was using a simple registry tweak

```
; This gives Dism.exe in System32 an Admin shield and makes it elevate the cmd so with UAC on it will give the UAC prompt.
[HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers]
"C:\\Windows\\System32\\Dism.exe"="RUNASADMIN"
```
 You can do this under HKEY_LOCAL_MACHINE but not needed unless you want all users to do this.









Yes I am a hardcore convicted registry tweaker sentenced to life for violating the registry and don't accept no for an answer if I want to do something. Might take awhile but I will figure most things out if it is at all possible. My system is AWESOME with targeted reg tweaks and .cmd files


----------

