Frage

I'm trying to write a batch file that will open computer management as an administrator (on a Windows 7 64 bit system). I have done this successfully with cmd but cannot get it to work with computer management. The command I have for cmd is: runas /profile /env /user:username@domain cmd After I authenticate with my pw, I'm good to go.

The commands I've tried for computer mgmt are: runas /profile /env /user:username@domain compmgmt.msc After I authenticate I get an error telling me "compmgmt.msc is not a valid Win32 application.

runas /profile /env /user:username@domain mmc After I authenticate I get an error telling me "The requested operation requires elevation"

If I run the good cmd option then type in either mmc or compmgmt.msc, the program will open as admin because I'm in cmd as admin already. I'm assuming there's a way to add onto the good cmd command to autopopulate that text into cmd and run it, but I don't know what it is. I'm also open to trying other options, really I just want a tool that works. I know that I can run my batch as admin and avoid all of this but the purpose of this tool is to not have to provide my admin username.

Suggestions?

War es hilfreich?

Lösung

runas /user:username@domain "cmd.exe /c \"start compmgmt.msc\""

If the .msc runs correctly from cmd, start cmd under the adecuated account and, from here, start the .msc

Andere Tipps

The problem is that you cannot run an .msc plugin without calling mmc. The correct call should be in this format:mmc.exe \location of plugin

runas /u:domain\user "mmc.exe \windows\system32\compmgmt.msc"

The start command will also work but relies on the extensions being properly entered in the registry. I usually do mmc \plugin location due to the different windows operating systems we use and the fact that usually half the plugins I want to use are not registered on the system for some reason.

better you travel to that location and then execute that file
You can write batch file which will run:

(CompMgmtLauncher.exe or CompMgmt.msc)

It'll look like

C:\Users\Admin>cd\

C:>cd Windows

C:\Windows>cd System32

C:\Windows\System32>CompMgmtLauncher.exe

C:\Windows\System32>compmgmt.msc

C:\Windows\System32>

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top