Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

Unable to automatically run elevated command prompt.


  • Please log in to reply

#1
zxcymn

zxcymn

    Member

  • Member
  • PipPip
  • 60 posts
I just recently formatted and installed Windows 7 Ultimate with Service Pack 1. I have a Take Ownership context menu item, but I can't use it without Command Prompt running as administrator every time it opens. Before I went to Service Pack 1 I was able to just right-click the command prompt and check to run it as an administrator, but now when I try that it says, "Compatibility modes cannot be set on this program because it is part of this version of Windows." and all the options are greyed out.

I didn't used to get that problem so I'm not sure how to proceed. I've tried setting myself as the owner of command prompt and granting it full access from the system and myself but it didn't change anything.


Please help :D

Edited by zxcymn, 09 April 2011 - 01:34 PM.

  • 0

Advertisements


#2
badassbiker

badassbiker

    Member

  • Member
  • PipPipPip
  • 109 posts
Howzit zxcymn,

Try the following:

Click START -> type cmd in the search box -> hit ctrl+shift+enter.

This should bring up an elevated command prompt.
  • 0

#3
zxcymn

zxcymn

    Member

  • Topic Starter
  • Member
  • PipPip
  • 60 posts
Thanks for the reply.

I can manually run it as administrator just fine. My problem is I can't right click it, go to the Compatibility tab and check "Run this program as administrator" so that it automatically runs elevated every time it's opened. I'm trying to use something I've used extensively in the past (before going to Service Pack 1), but it won't work unless the command prompt starts elevated on its own. Below is a picture of why I'm unable to check it.

Posted Image
  • 0

#4
badassbiker

badassbiker

    Member

  • Member
  • PipPipPip
  • 109 posts
I have noticed that I have the same issue. :D

Maybe you could try using the "runas" command in a shortcut as a workaround:

runas /noprofile /user:[email protected] cmd.exe


I will investigate further...
  • 0

#5
zxcymn

zxcymn

    Member

  • Topic Starter
  • Member
  • PipPip
  • 60 posts
Thanks for the reply!

I'm not sure how I would make this context menu go through a shortcut. It's a .reg that when added, creates a context menu where you can right click on a folder and take ownership of every item in it without having to sit there and type all the commands out. Perhaps if I post the contents of the file, someone can maybe point out something to change in it so that it runs an elevated command prompt? Here are the contents if this is possible:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\takeownership]
@="Take ownership"
"HasLUAShield"=""
"NoWorkingDirectory"=""

[HKEY_CLASSES_ROOT\*\shell\takeownership\command]
@="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F"
"IsolatedCommand"="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F"

[HKEY_CLASSES_ROOT\exefile\shell\takeownership]
@="Take ownership"
"HasLUAShield"=""
"NoWorkingDirectory"=""

[HKEY_CLASSES_ROOT\exefile\shell\takeownership\command]
@="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F"
"IsolatedCommand"="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F"

[HKEY_CLASSES_ROOT\dllfile\shell\takeownership]
@="Take ownership"
"HasLUAShield"=""
"NoWorkingDirectory"=""

[HKEY_CLASSES_ROOT\dllfile\shell\takeownership\command]
@="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F"
"IsolatedCommand"="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F"

[HKEY_CLASSES_ROOT\Directory\shell\takeownership]
@="Take ownership"
"HasLUAShield"=""
"NoWorkingDirectory"=""

[HKEY_CLASSES_ROOT\Directory\shell\takeownership\command]
@="cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t"
"IsolatedCommand"="cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t"

  • 0

#6
badassbiker

badassbiker

    Member

  • Member
  • PipPipPip
  • 109 posts
Have a look here
  • 0

#7
zxcymn

zxcymn

    Member

  • Topic Starter
  • Member
  • PipPip
  • 60 posts
My apologies if this comes off as rude, but I've explained multiple times that the context menu doesn't open a shortcut. I don't need to know how to elevate it through a shortcut because the context menu opens the direct cmd.exe so please, no more shortcut how-to's. I need to know how to be able to get a check beside "Run this program as an administrator" when it's greyed out.
  • 0

#8
badassbiker

badassbiker

    Member

  • Member
  • PipPipPip
  • 109 posts
I misunderstood your request. :D

It seems that this will only work if you are running the command from an Administrator's account.
  • 0

#9
zxcymn

zxcymn

    Member

  • Topic Starter
  • Member
  • PipPip
  • 60 posts
Anyone else have any idea? :)
  • 0

#10
zxcymn

zxcymn

    Member

  • Topic Starter
  • Member
  • PipPip
  • 60 posts
Fix for the problem in case someone else has this and finds this thread:

In the registry editor, navigate to "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" (If there isn't a Layers folder, you'll have to create one)
For the value, make it the full path to command prompt. (i.e. C:\Windows\System32\cmd.exe and without quotes) and the data of that value "RUNASADMIN" without quotes.
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP