Solved Toggle "Run as Administrator" compatibility option from context menu?

arrestme

New member
Local time
3:01 PM
Messages
11
Toggle "Run as Administrator" compatibility option from context menu?

I've definitely looked my way around the net for this one, but alas, she's a hard one for those search engines & me to make any sense of for what I'm specifically trying to find a way to do.

I've made a few of my own context menu shortcuts (copy file path / create dir filelist /reg backup/create sys restore / toggle firewall block status / toggle hide protected system files / file+folder unblock) cuz I do a lot of things repetitively & they really make things much quicker for day2day tasking.

So basically I have 2 questions for the smart ones out there who could teach a noob like me a few things. If not teach, then just share? <3

1.) Like title says BUT without opening it; I want to skip having to go to properties of the file -> click compatibility tab -> check "Run this program as an administrator" under Privilege Level -> then click "Change settings for all users" -> to then click the box again (I know i can just click the 2nd box and skip checking the 1st, but ya kno wut i'm saying; making sure both get applied). ->clicking OK -> then clicking OK = just to make sure that particular file will always run as admin whether thru a shortcut or not.
Can I make a .bat file or must I do a wscript for that? (I can then take that & add into context menu to my preference, but not important) or maybe even a less-intrusive method? You will save my neck some sweet sweet second fractions guys! :D

also, if u have the time to spare;
2.) How would I have been able to find these options out on my own? If this is the harder question of the 2, feel free to skip.

Here's a quick example if I'm talking too much to be clear:
Y6FwqsI.png


Thanks a ton everyone. LONGGGGG time viewer, first time poster. Hope ya'll are good. :cool:
 

My Computer My Computer

At a glance

Windows 7 ultimate x64AMD Phenom II X4 B506144 MBytes DDR2AMD Radeon HD 7800 Series
Computer type
PC/Desktop
OS
Windows 7 ultimate x64
CPU
AMD Phenom II X4 B50
Motherboard
Gigabyte GA-MA790X-UD4P
Memory
6144 MBytes DDR2
Graphics Card(s)
AMD Radeon HD 7800 Series
Sound Card
High Definition Audio Device
Screen Resolution
1600X1200
Hard Drives
SAMSUNG HD502HJ ATA Device 465 GB
OCZ-ARC100 SSD Drive 111 GB
Mouse
AlienWare
Hi Arrestme, and thank you for joining Seven Forums,

And nice image there.

Those compatibility configurations are saved to the registry. Specifically to the key of
  • HKCU\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers
or instead
  • HKLM\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers
if the settings should apply for all users. Note that that second location, in HKLM, is a virtual key (a.k.a. "hidden registry key") so don't expect to be able to search it through RegEdit.

When a compatibility setting is configured on an application, the path of that executable is written to the according registry key, as a value. And the value's data contains the compatibility configuration information for that executable, in the form of a space separated list of strings, each string called a 'flag'.

The flag for configuring an application to run with administrative rights is 'RUNASADMIN'.


E.g. Instead of using the gui to set the "Run this program as an administrator" compatibility setting for all users, one could alternatively choose to run the command
Code:
reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v "C:\path\to\FL.exe" /t "REG_SZ" /d "RUNASADMIN"
to succeed the same effect. (N.B., generally, writing to the HKLM hive requires local administrative rights, so an elevated command prompt would be needed.)


Can I make a .bat file or must I do a wscript for that? (I can then take that & add into context menu to my preference, but not important)
Yes. If you can do the adding-to-the-context-menu part, I may be able to create some VBScript that aptly writes to the registry for you.

However, unfortunately, you'll have to abandon the idea of being able to configure the "Run this program as an administrator" compatibility setting for all users, because you'll have a hard time getting the script to run as administrator, launching it from the context menu (as 'HKLM\Software\...\Layers' requires administrative permissions to modify).


Toggle Run as Admin.vbs
Code:
' ToggleRunAsAdmin.vbs ExeFile
' Toggle the "Run this program as an administrator" compatibility setting on 'ExeFile'.
 
Function PromptForElevation
    If Not CreateObject("WScript.Shell").Run("Net Sess", 0, True) = 0 Then
        CreateObject("Shell.Application").ShellExecute "WScript", _
                """" & WScript.ScriptFullName & """" & " " & """" & WScript.Arguments.Item(0) & """", "","RunAs",1
        WScript.Quit
    End If
End Function
 
If WScript.Arguments.Unnamed.Count = 0 Then WScript.Quit(1)
If WScript.Arguments.Item(0) = "" Then WScript.Quit(1)
 
Const HKCU = &H80000001 'HKEY_CURRENT_USER
Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
 
'PromptForElevation()
 
Set reLetters = New RegExp
reLetters.Pattern = "[a-z]"
reLetters.IgnoreCase = True
reLetters.Global = True
 
Set reRunAsAdmin = New RegExp
reRunAsAdmin.Pattern = " *RUNASADMIN *"
reRunAsAdmin.IgnoreCase = True
reRunAsAdmin.Global = True
 
hDefKey   = HKCU
strSubKey = "Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"
strValue  = WScript.Arguments.Item(0)
strData   = "RUNASADMIN"
 
Set objReg = GetObject("WinMgmts:\\.\root\default:StdRegProv")
 
objReg.GetStringValue hDefKey, strSubKey, strValue, ExistingData
 
If IsNull(ExistingData) Then
    objReg.SetStringValue hDefKey, strSubKey, strValue, strData
Else
    If reLetters.Test( Replace(ExistingData, strData, "") ) Then
        If reRunAsAdmin.Test( ExistingData ) Then
            objReg.SetStringValue hDefKey, strSubKey, strValue, reRunAsAdmin.Replace(ExistingData, "")
        Else
            objReg.SetStringValue hDefKey, strSubKey, strValue, ExistingData & " " & strData
        End If
    Else
        objReg.DeleteValue hDefKey, strSubKey, strValue
    End If
End If
 
Last edited:

My Computer My Computer

At a glance

Windows 10, Windows 8.1 Pro, Windows 7 Profes...
Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
Hello there & thankyou for the welcome. I'd like to quickly do a preface response with a quick HELLZ yea for this Gentleman & Scholar; Pyprohly. I once was lost but now I am found m'i'right people? Didn't feel right sinking into such a fruitful share without first saying hello, so if you don't mind, I'm like a kid in a candy store waiting to bite into this beautiful knowledgecopia. I'll be back for afterthoughts bro. :D
 

My Computer My Computer

At a glance

Windows 7 ultimate x64AMD Phenom II X4 B506144 MBytes DDR2AMD Radeon HD 7800 Series
Computer type
PC/Desktop
OS
Windows 7 ultimate x64
CPU
AMD Phenom II X4 B50
Motherboard
Gigabyte GA-MA790X-UD4P
Memory
6144 MBytes DDR2
Graphics Card(s)
AMD Radeon HD 7800 Series
Sound Card
High Definition Audio Device
Screen Resolution
1600X1200
Hard Drives
SAMSUNG HD502HJ ATA Device 465 GB
OCZ-ARC100 SSD Drive 111 GB
Mouse
AlienWare
I knew being uber polite might come in handy bro, cuz i can't figure it out man I äm stuck. :o
This was my last step I took for context menuing for exes. Wrong spot maybe or something?

Everything seems to be how u said it should. It goes up onto the context menu, but when i click it no script loads, the options dont change and i even chacked in registry for some reason it didnt right it there either (prob pointless to check there after, but had to make sure hehe)
Code:
[HKEY_CLASSES_ROOT\exefile\shell\Set Run as Admin]
"Icon"="\"C:\\Windows\\System32\\rekeywiz.exe\""
@="Run always as Admin"
[HKEY_CLASSES_ROOT\exefile\shell\Set Run as Admin\command]
@="WScript C:\\Windows\\ToggleRunasAdmin.vbs"

Code:
' Toggle_Run_as_Admin.vbs ExePath
' Toggle the "Run this program as an adminstrator" compatibility setting on 'ExePath' for the current user.
 
Const HKCU = &H80000001 'HKEY_CURRENT_USER
Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
 
If WScript.Arguments.Unnamed.Count = 0 Then WScript.Quit(1)
If WScript.Arguments.Item(0) = "" Then WScript.Quit(1)
 
strSubKey = "Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"
strValue  = WScript.Arguments.Item(0)
strData   = "RUNASADMIN"
 
Set objReg = GetObject("winmgmts:\\.\root\default:StdRegProv")
 
objReg.GetStringValue HKCU, strSubKey, strValue, Exists
 
MsgBox(IsNull(Exists))
 
If IsNull(Exists) Then
    objReg.SetStringValue HKCU, strSubKey, strValue, strData
Else
    objReg.DeleteValue HKCU, strSubKey, strValue
End If

Am I doing it wrong bruh? I added contexts in HKCR\exefile\shell\Set Run as Admin\command & it points to the vbs toggle script...
I've officially tried everything except the bat file so far, because I wanted to ask what you thought about a possible bypass to not abandon the all users setting, aka getting the script to run as admin from context to write to HKLM/.../layers. Could adding the location of the vscript manually to HKLM/.../layers with the proper path & RUNASADMIN value? So then not all vscripts will b able to run as admin for safety reasons (otherwise we could've just added wscript.exe to layers, but possibly unsafe in case?). Then it launches the script with admin every time? I kno u can launch .vbs as admin with special right click trick & others, so it might work no? Otherwise, what if I just take permissions & ownership of folder? Could the script write to it under different username besides admin if changed rights? Was I on to something with the first guess & Just embarassing myself more with these last ones? Doh! Once again thanks bro.
 

My Computer My Computer

At a glance

Windows 7 ultimate x64AMD Phenom II X4 B506144 MBytes DDR2AMD Radeon HD 7800 Series
Computer type
PC/Desktop
OS
Windows 7 ultimate x64
CPU
AMD Phenom II X4 B50
Motherboard
Gigabyte GA-MA790X-UD4P
Memory
6144 MBytes DDR2
Graphics Card(s)
AMD Radeon HD 7800 Series
Sound Card
High Definition Audio Device
Screen Resolution
1600X1200
Hard Drives
SAMSUNG HD502HJ ATA Device 465 GB
OCZ-ARC100 SSD Drive 111 GB
Mouse
AlienWare
Code:
[HKEY_CLASSES_ROOT\exefile\shell\Set Run as Admin]
"Icon"="\"C:\\Windows\\System32\\rekeywiz.exe\""
@="Run always as Admin"
[HKEY_CLASSES_ROOT\exefile\shell\Set Run as Admin\command]
@="WScript C:\\Windows\\ToggleRunasAdmin.vbs"
Am I doing it wrong bruh? I added contexts in HKCR\exefile\shell\Set Run as Admin\command & it points to the vbs toggle script...
Very close. You forgot to pass the file as a parameter to the script.
E.g.
Code:
[HKEY_CLASSES_ROOT\exefile\shell\Set Run as Admin]
@="Run always as Admin"
"Icon"="\"C:\\Windows\\System32\\rekeywiz.exe\""
 
[HKEY_CLASSES_ROOT\exefile\shell\Set Run as Admin\command]
@="WScript \"C:\\Windows\\ToggleRunasAdmin.vbs\" [COLOR=red][B]%1[/B][/COLOR]"


Now on to the topic of elevating the script itself...

I've officially tried everything except the bat file so far, because I wanted to ask what you thought about a possible bypass to not abandon the all users setting, aka getting the script to run as admin from context to write to HKLM/.../layers.
Except the bat file? What bat file? Anyway, so I've added a function to the VBScript that will prompt you for elevation, which will run the script as administrator should you accept it's UAC dialogue. Uncomment line 18 to enable this behaviour. After doing so, you will be able to write to 'HKLM\...\Layers' (upon accepting the UAC).

In the script, line 30, edit "hDefKey = HKCU" to "hDefKey = HKLM" to write to 'HKLM\...\Layers' instead, i.e., to save the RUNASADMIN configuration setting for all users.

If you happen to find the UAC dialogue excessive, you can choose to go about changing the permissions of the 'HKLM/.../layers' key, and make it have similar access rules to 'HKCU/.../layers' so that no administrative rights would be required to edit the key. But because 'HKLM/.../layers' exists as a virtural key it is going to be a little tricky to make possible those changes.

Could adding the location of the vscript manually to HKLM/.../layers with the proper path & RUNASADMIN value? So then not all vscripts will b able to run as admin for safety reasons (otherwise we could've just added wscript.exe to layers, but possibly unsafe in case?).
You may not add anything but exe files to 'HKLM\...\Layers' (well you can but it won't do anything) as only programs can have compatibility configurations. You could add the WScript engine to the list. That will work, however, any script that tries to run using that engine, you'll have to always explicitly allow it to do so by first accepting a UAC dialogue. It won't be unsafe or pose any security risks because of this, but it will become annoying.


Was I on to something with the first guess & Just embarassing myself more with these last ones? Doh! Once again thanks bro.
You, sir, are very computer literate.
 

My Computer My Computer

At a glance

Windows 10, Windows 8.1 Pro, Windows 7 Profes...
Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
Wehehehelll.. (straightens cufflinks) I do dabble. lol just kidding more like involuntary lifestyle choice. xD

Oh sweet! This just in, LIGHTENING HAS STRUCK, I REPEAT THE EAGLE HAS LANDED! It works! Tweaked that quick parameter for the script pass, elevating the ball FAR with help of quick UAC by uncommenting line 18... and decides to put HKCU on the bench to make way for.... HKLM? Now this is unprecedented....ladies and gentleman we - 1second..whats this? HKLM is closing in fast towards the endzone at line 30?? WHAAAT!? OMG HKLM catches the script parameter just in the nick of time! YES!! GO!! YEEEEES Team Bruh WINS the championship!!!! GO TEAM BRUH!!! #crowd_cheers #coach_Pyprohly_gets_gatoraided #freeze_frame_showing_arrestme_carried_off_with_trophy_and_sees_Pyprohly_looking_on_like_Mr_Miyagi_at_end_of_Karate_Kid #superimposed_text_fades_in_-_Arrestme_goes_on_to_become_president_of_the_universe_Pyprohly_goes_beyond_to_other_galaxies_spreading_adventure_and_learning_still_to_this_day. #long_ass_hashtags lmao

I may have already changed the permissions in registry or made myself owner before because no UAC.
 

My Computer My Computer

At a glance

Windows 7 ultimate x64AMD Phenom II X4 B506144 MBytes DDR2AMD Radeon HD 7800 Series
Computer type
PC/Desktop
OS
Windows 7 ultimate x64
CPU
AMD Phenom II X4 B50
Motherboard
Gigabyte GA-MA790X-UD4P
Memory
6144 MBytes DDR2
Graphics Card(s)
AMD Radeon HD 7800 Series
Sound Card
High Definition Audio Device
Screen Resolution
1600X1200
Hard Drives
SAMSUNG HD502HJ ATA Device 465 GB
OCZ-ARC100 SSD Drive 111 GB
Mouse
AlienWare
hmm now wait a minute...I forgot I was testing on an exe file I had isolated in a folder I had taken as owner and given my only full privilege. It changed that with no UAC. But going to...lets say my batman.exe...the same thing happens as before, no change with no UAC even. theyre gonna take away my universe presidency :( A SEQUEL? :D
 

My Computer My Computer

At a glance

Windows 7 ultimate x64AMD Phenom II X4 B506144 MBytes DDR2AMD Radeon HD 7800 Series
Computer type
PC/Desktop
OS
Windows 7 ultimate x64
CPU
AMD Phenom II X4 B50
Motherboard
Gigabyte GA-MA790X-UD4P
Memory
6144 MBytes DDR2
Graphics Card(s)
AMD Radeon HD 7800 Series
Sound Card
High Definition Audio Device
Screen Resolution
1600X1200
Hard Drives
SAMSUNG HD502HJ ATA Device 465 GB
OCZ-ARC100 SSD Drive 111 GB
Mouse
AlienWare
Haha. Creative.

Now lets find out what broke here... did some debugging and found a issue to do with paths and spaces in them. To fix this, we must make a small change to the reg file, specifically how it passes that parameter, again: needs quotes 'round it is all.
Code:
[HKEY_CLASSES_ROOT\exefile\shell\Set Run as Admin]
"Icon"="\"C:\\Windows\\System32\\rekeywiz.exe\""
@="Run always as Admin"
[HKEY_CLASSES_ROOT\exefile\shell\Set Run as Admin\command]
@="WScript \"C:\\Windows\\ToggleRunAsAdmin.vbs\" [COLOR="red"][B]\"[/B][/COLOR]%1[COLOR="Red"][B]\"[/B][/COLOR]"


I forgot I was testing on an exe file I had isolated in a folder I had taken as owner and given my only full privilege. It changed that with no UAC. But going to...lets say my batman.exe...the same thing happens as before, no change with no UAC even.
The script should always work, no matter how badly denied you are to the file being acted on. It's the registry keys permissions that really count here.

If line 18 is uncommented, you should always receive a UAC prompt.


A SEQUEL? :D
Preparing my popcorn...
 

My Computer My Computer

At a glance

Windows 10, Windows 8.1 Pro, Windows 7 Profes...
Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
Baboom! haha yes you scored a hat trick helping me out thrice! Aw, we ran out of gatoraid. :(
Yea I was wondering wut was going on cuz instead of just the file, it ended up pertaining to that whole partition letting me write to their exes, & not the main one

....so I went on a little "permission impossible" I guess on my own yesterday. lol
Of course it was my own doing who was the culprit XD but that's why these context things get me learning the most interesting things. Thanks once again man. Hope you getting paid for this cuz u should!

I might make another thread asking about this chain of Python scripts that piggyback on one another, & I been trying to figure out a way to use these Python2Exe programs, which I haven't gotten to work ever. I think it's because of the piggybacking modules. This also piggybacks on my complete lack of Python knowledge at all...I was ridiculed to a crisp in their support IRC. Not sure if I should go find the section that post could go in, to specifically ask for somebody to get the files from me, see how they work, then use their knowledge to use the Python2Exe program for me, since i guess at a lot of the settings.

A lot of people would benefit, if u kno anyone who might help me with that. It's a Python/PGU/Pygame OSD of live virtualized feed of a plugged in USB Gamecube Controller. It's used for streaming & what-not, but NOBODY uses it, because it requires all these plugins & basic knowledge of installing things for windows/python, but MOSTLY it's the 2nd reason; to stream it live in your "Scene", it can't have anything over it's window, & b completely visible at all times, which is counterproductive sometimes. If it were an EXE, you not only wouldn't need any of the python scripts/modules/programs anymore to run it, but you could then layer it on your streaming screen "scene" as a "game", or even other media, thereby not needing it to be visible or unobstructed to live feed through it's scene layer.

The above is all complicated, but rly the program isn't supposed to be, I'm just overheated having basically quit streaming for weeks cuz of it. All of the modules/scripts/etc are all verifiable as well & safe. Thanks again for everthing hombre. You're the "El Chapo" of tech. :D
 

My Computer My Computer

At a glance

Windows 7 ultimate x64AMD Phenom II X4 B506144 MBytes DDR2AMD Radeon HD 7800 Series
Computer type
PC/Desktop
OS
Windows 7 ultimate x64
CPU
AMD Phenom II X4 B50
Motherboard
Gigabyte GA-MA790X-UD4P
Memory
6144 MBytes DDR2
Graphics Card(s)
AMD Radeon HD 7800 Series
Sound Card
High Definition Audio Device
Screen Resolution
1600X1200
Hard Drives
SAMSUNG HD502HJ ATA Device 465 GB
OCZ-ARC100 SSD Drive 111 GB
Mouse
AlienWare
I'm glad you have found the assistance resourceful.


Sadly, I cannot help you with your Python problem, nor likely can this forum at this time.

Where ever you create your said thread, I do not recommend you create such a thread here, in assertion that you will not get an answer, or even a reply, because Python remains out of the scope of knowledge which this forum is able to provide, and the stated problem is better suited for its respective forum. Unfortunately, I don't know of one, or if one exists at this stage.

If you really do get desperate though, my average enough experience in Python got me successfully compiling Python 3 scripts once, but that was some while ago—never really had the need to compile them—I prefer them in script form, readable, all the time. While I may be able to help you compile that Python 2 script of yours, that's as far as I will go on that one. I've never touched a Python script that has a gui before.

If you want to continue discussing this Python problem here, please PM me instead. But I encourage you look elsewhere for help first.

Good luck, Arrestme.
 

My Computer My Computer

At a glance

Windows 10, Windows 8.1 Pro, Windows 7 Profes...
Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
Thanks man, I completely understand. You absolutely still rock! Respect Mr.Miyagi.
 

My Computer My Computer

At a glance

Windows 7 ultimate x64AMD Phenom II X4 B506144 MBytes DDR2AMD Radeon HD 7800 Series
Computer type
PC/Desktop
OS
Windows 7 ultimate x64
CPU
AMD Phenom II X4 B50
Motherboard
Gigabyte GA-MA790X-UD4P
Memory
6144 MBytes DDR2
Graphics Card(s)
AMD Radeon HD 7800 Series
Sound Card
High Definition Audio Device
Screen Resolution
1600X1200
Hard Drives
SAMSUNG HD502HJ ATA Device 465 GB
OCZ-ARC100 SSD Drive 111 GB
Mouse
AlienWare
Hello again my favorite Guru. I have a new question about a request pertaining to this thread, so not sure if I should make a new one. I'm only certain you would have the exact answer I'm looking for. If it should be somewhere else or something like that, I'll be happy to do it. Not sure what rules are on posting in already solved threads. But the answer I should've asked you about before would help anyone else coming across this particular thread.

I'm wondering how to make the context menu's "title", of our addition you helped me create, change depending on if it is already active or not. I found that this shortcut was amazing, but if I forgot if I activated it or not, I'd have to go into the properties menu anyway, voiding the saved time.

So right now if I click on an unmodified exe, I can click the "Always Admin" context, which would make it run as admin on all users. Let's say I do that & now it's checked. If I right click again, is there a way to have windows know if it's already been checked? & If it is checked, can it change the context menu to say something like "Always Admin OFF"? This way in the process of wanting to activate "Always Admin" I can see if I've already done it before or not with assurance.

Sorry to bother you again with this, but it has been a huge difference in menial tasks. I'm just not exactly sure how to alter this set-up to make that slight change. The script you provided is already set up to run a check on if the All User Run as Admin is checked, & then will uncheck it if I run it again on the same exe. But it would be so nice if the text I'm clicking could somehow indicate if it's already checked or not by a change of text. Hope I was explicit enough in describing. You seemed to have very good tact in dealing with broad descriptions by people who don't know these technical coding languages.

Thanks again if you're still around. If you've moved on & somebody else is now in charge of reading this, I implore you to help as well. If you can fill Pyprohly here's shoes. ^_^
 

My Computer My Computer

At a glance

Windows 7 ultimate x64AMD Phenom II X4 B506144 MBytes DDR2AMD Radeon HD 7800 Series
Computer type
PC/Desktop
OS
Windows 7 ultimate x64
CPU
AMD Phenom II X4 B50
Motherboard
Gigabyte GA-MA790X-UD4P
Memory
6144 MBytes DDR2
Graphics Card(s)
AMD Radeon HD 7800 Series
Sound Card
High Definition Audio Device
Screen Resolution
1600X1200
Hard Drives
SAMSUNG HD502HJ ATA Device 465 GB
OCZ-ARC100 SSD Drive 111 GB
Mouse
AlienWare
Hi again Arrestme,

I'm still alive and healthy. And I'm glad you are still finding the content here useful.

I understand exactly what you're asking for, but unfortunately there isn't such a thing as having a dynamic title for a content menu entry. Though what you describe would be highly convienient, there are two barriers from one being able to achieve this: firstly, the sole job of a context menu item is to trigger something (in this case a script), and it makes no calculations. The script is the thing that determines whether the Run as Admin setting is actually enabled or not and carries out the according action. Because context menu items aren't able to make calculations, if one wanted a context menu entry with a dynamic title then some sort of program or script must run each time the user right-clicks and then quickly change a registry value. I'm doubtful Windows will allow this. Secondly, modifying, adding or deleting a context menu item requires administrative permissions, thus if the title of a context menu were to change, the user would have to accept UAC each time.

So it's not possible to have the title of "Run always as Admin" change according to whether the Run as Admin capatibility setting is enabled or not; you can only change the behaviour of the script.

What you could do is modify the script to ask you if you want to toggle the setting, it'll indicate whether or not the program is currently set to Run as Admin through a popup box. Pressing enter to this popup will change the program's Run as Admin state. Waiting 1.5 seconds will cause the box to disappear with no action being taken.

Is this a practical idea? Try it out, Arrestme, and tell me what you think.


ToggleRunAsAdmin_2.vbs
Code:
' ToggleRunAsAdmin_2.vbs ExeFile
' Toggle the "Run this program as an administrator" compatibility setting on 'ExeFile'.

Set WshShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set objReg = GetObject("WinMgmts:\\.\root\default:StdRegProv")

Function PromptForElevation(Args)
	If Not WshShell.Run("Net Sess", 0, True) = 0 Then
		CreateObject("Shell.Application").ShellExecute "WScript", _
				"""" & WScript.ScriptFullName & """" & " " & """" & WScript.Arguments.Item(0) & """" & " " & Args, "","RunAs",1
		WScript.Quit
	End If
End Function

Function EnableRunAsAdmin(hDefKey, strSubKey, strValue, strData)
	objReg.SetStringValue hDefKey, strSubKey, strValue, strData
End Function

Function DisableRunAsAdmin(hDefKey, strSubKey, strValue, strData)
	If reLetters.Test( Replace(ExistingData, strData, "") ) Then
		If reRunAsAdmin.Test( ExistingData ) Then
			objReg.SetStringValue hDefKey, strSubKey, strValue, reRunAsAdmin.Replace(ExistingData, "")
		Else
			objReg.SetStringValue hDefKey, strSubKey, strValue, ExistingData & " " & strData
		End If
	Else
		objReg.DeleteValue hDefKey, strSubKey, strValue
	End If
End Function

If WScript.Arguments.Unnamed.Count = 0 Then WScript.Quit 1
If WScript.Arguments.Item(0) = "" Then WScript.Quit 1

Const StopIcon		  = 16
Const QuestionIcon	  = 32
Const ExclamationIcon = 48
Const InformationIcon = 64

Const YesNoCancelButtons = 3
Const YesNoButtons		 = 4

sngWaitSeconds = 1.5

Const HKCU = &H80000001 'HKEY_CURRENT_USER
Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE

hDefKey	  = HKCU 'Use HKCU (toggle setting for current user only) or HKLM (toggle setting for all users)
strSubKey = "Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"
strValue  = WScript.Arguments.Item(0)
strData	  = "RUNASADMIN"

strRunOnceKey = "Software\Microsoft\Windows\CurrentVersion\RunOnce"

Set reLetters = New RegExp
reLetters.Pattern = "[a-z]"
reLetters.IgnoreCase = True
reLetters.Global = True

Set reRunAsAdmin = New RegExp
reRunAsAdmin.Pattern = " *RUNASADMIN *"
reRunAsAdmin.IgnoreCase = True
reRunAsAdmin.Global = True

If WScript.Arguments.Named.Exists("enable") Then
	EnableRunAsAdmin hDefKey, strSubKey, strValue, strData
	objReg.SetStringValue HKCU, strSubKey, strValue, strData
	If Not objReg.EnumKey(HKCU, strRunOnceKey) = 0 Then
		objReg.CreateKey HKCU, strRunOnceKey
	End If
	Randomize
	strRegDelCmd = "reg delete " & """HKCU\" & strSubKey & """ /v """ & strValue & """ /f"
	objReg.SetStringValue HKCU, strRunOnceKey, fso.GetFileName(WScript.ScriptFullName) & "_" & Int(Rnd * 1000000), strRegDelCmd
	WScript.Quit 0
ElseIf WScript.Arguments.Named.Exists("disable") Then
	DisableRunAsAdmin hDefKey, strSubKey, strValue, strData
	objReg.DeleteValue HKCU, strSubKey, strValue
	WScript.Quit 0
End If

objReg.GetStringValue hDefKey, strSubKey, strValue, ExistingData

If IsNull(ExistingData) Then
	intSelection = WshShell.Popup("Enable run as administrator compatibility setting?", sngWaitSeconds, "Run as Administrator is Disabled", InformationIcon + YesNoCancelButtons)
	If intSelection = 6 Then
		If hDefKey = HKLM Then
			PromptForElevation("/enable")
		Else
			EnableRunAsAdmin hDefKey, strSubKey, strValue, strData
		End If
	End If
	WScript.Quit 0
Else
	intSelection = WshShell.Popup("Disable run as administrator compatibility setting?", sngWaitSeconds, "Run as Administrator is Enabled", ExclamationIcon + YesNoCancelButtons)
	Select Case intSelection
		Case 6
			If hDefKey = HKLM Then
				PromptForElevation("/disable")
			Else
				DisableRunAsAdmin hDefKey, strSubKey, strValue, strData
			End If
		Case Else
			WScript.Quit 0
	End Select
End If

I've also made a few reliablity improvements to the above script since the previous one.
 

My Computer My Computer

At a glance

Windows 10, Windows 8.1 Pro, Windows 7 Profes...
Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
Such a smart person this guy. It's awe inspiring every time! Allow me to prepare a response & I apologize for taking so long. I didn't have as much time as I'd hoped to get back to you, so once again thank you for replying with this in almost record time & forgive me lateness in reply. I also wanted to go through your script & mess around with it some-what. :D

I'll try & hash it out quickly as it seems to be only 1 issue probably due to my quagmire of requests on this shortcut thing, taking time from what I assume is your seriously busy posting schedule here.

So I really like the box pop-ups, tho I'm not sure if I can accurately appreciate the upgrades you've made to the script. Tho I did see the comparison with the old one using "text different with this file..." in PSPad, I'm simply just not sure if I'm trained enough to recognize & understand all of the cool differences you author here for us. But I'm super grateful ya did it again none-the-less. That should be your slogan (fixed it again)! :D

But ok this 1 problem I'm sure you'll recognize straight away is that running the script thru context menu of a right clicked unmodified .exe, obviously shows the beautiful notice with a title on top showing "Run as Admin is Disabled (& will actually change to enabled if enabled)" including 3 options for us to use after going from there: Yes No & Cancel. Beautiful, really I love it.

But maybe it's me being a stickler but since *I have the "All Users" "Run as Admin" box getting checked from the previous script, if I run this new script on an already-modified-exe that has All Users Run-as-Admin activated, the new script will show up as "Run as Admin is disabled", making clicking yes or no or cancel all doing nothing, unable to check/uncheck the normal RAAdmin since setting the option for the All-Users tab, greys out the old "normal" one.

So, again I'm gonna be a super burden & ask if you can do something like what I have had for "hide/unhide hidden system files" context menu shortcut option. I had the same problem with where I couldn't have the context menu show the status of the options i wanted to toggle in it's name alone, so at the end of the script running, a pop-up notification like you have but a bit different would come up:

Code:
If dblHiddenData = 0 Then
	WshShell.RegWrite strSuperHiddenKey, 1, "REG_DWORD"
	WScript.Echo "Now SHOWING protected system files."

Else
	WshShell.RegWrite strSuperHiddenKey, 0, "REG_DWORD"
	WScript.Echo "Now HIDING protected system files."

I don't know if I'm pandering too much, but *if you could change the script to skip UAC's while enabling the All Users RAA with 1 option pop-up, I'd be once again amazed & indebted to your suave and powerful brain.

I was wondering if the script being able to do that all with the All-Users option of RAA was not too much of a bother, if you could make the pop-up with a simple "OK" button for all incidents & the inside-box description with an announcement of if it activated it or not. With what you made possible with your script update, & because of it I'd then know both status of 1.)if it was already activated/deactivated before clicking & 2.) if I had just activated/deactivated it. Then I could go from there. Which gives me another idea! :D
I'm pushing harder here, but i'm hoping it turns into something maybe you yourself might even use! :D
But now that I think of it ..if you've gotten this far, is it possible to have 1 pop-up box after clicking "always admin", no matter whether the script is checking or unchecking the RAA box? With just a few exception: The pop-up comes after script as already done it's work instead of before, & it's contents of having your "Run as Admin is now Disabled[or Enabled]!" at the top perfectly like you made it, but with the words below that (yet above the buttons) instead of having, "Enable[or disable] run as admin comp setting?" with options "Yes, No, & Cancel", instead can it say "Continue or REVERSE changes?" with options in 2 boxes of "OK" or "Reverse"?.


So the script does all the work before notifying you with the options. Then you can choose OK to move on if you're happy with the outcome, or "REVERSE" button that will turn back the action it just made. Is something like that possible? Would I need another script for the reverse? Is this too much of a headache? Or will we possibly make the best script ever in the history of Windows 7? :D :D :D

*Does running it as admin for All Users or not make any difference at all even if I'm the only user on the PC? I only am specifying toward the all-user run-as-admin box because I'm thinking it must cover all my bases. Or, for my purposes, would I not ever come across needing that specifically checked over the other "normal" run-as-admin properties box being checked? If there really is no difference, than no need to make any harrowing code tricks just to get the "ALL USER" version to check on/off. If so, & if it'd save you time, the other would be just fine.
 

My Computer My Computer

At a glance

Windows 7 ultimate x64AMD Phenom II X4 B506144 MBytes DDR2AMD Radeon HD 7800 Series
Computer type
PC/Desktop
OS
Windows 7 ultimate x64
CPU
AMD Phenom II X4 B50
Motherboard
Gigabyte GA-MA790X-UD4P
Memory
6144 MBytes DDR2
Graphics Card(s)
AMD Radeon HD 7800 Series
Sound Card
High Definition Audio Device
Screen Resolution
1600X1200
Hard Drives
SAMSUNG HD502HJ ATA Device 465 GB
OCZ-ARC100 SSD Drive 111 GB
Mouse
AlienWare
Sorry for my buttery way of spreading my questions & explanation all over the place; but here I wanted to point out PyProhly's adroitness & accuracy for knowing exactly where I'm coming from & superb in every respect through every response. I only continue to add to this thread for my own selfish reasons, & not due to any problem with his (or her?) advice. This is 1 smart person & very glad to have worked with him on this. Cuz this is probably the last request of mine. It's been real! :D
 
Last edited:

My Computer My Computer

At a glance

Windows 7 ultimate x64AMD Phenom II X4 B506144 MBytes DDR2AMD Radeon HD 7800 Series
Computer type
PC/Desktop
OS
Windows 7 ultimate x64
CPU
AMD Phenom II X4 B50
Motherboard
Gigabyte GA-MA790X-UD4P
Memory
6144 MBytes DDR2
Graphics Card(s)
AMD Radeon HD 7800 Series
Sound Card
High Definition Audio Device
Screen Resolution
1600X1200
Hard Drives
SAMSUNG HD502HJ ATA Device 465 GB
OCZ-ARC100 SSD Drive 111 GB
Mouse
AlienWare
My turn for an apologetic sentence regarding my response time. I had a few issues with making the script work with your specifications and in a feasible manner. But I did manage make much improvements to the behaviour of the RAA All Users setting.

But maybe it's me being a stickler but since *I have the "All Users" "Run as Admin" box getting checked from the previous script, if I run this new script on an already-modified-exe that has All Users Run-as-Admin activated, the new script will show up as "Run as Admin is disabled", making clicking yes or no or cancel all doing nothing, unable to check/uncheck the normal RAAdmin since setting the option for the All-Users tab, greys out the old "normal" one.
It's because you've had the other script in HKLM mode, which set the Run as Admin flag for All Users. Conversely, when you acquired the new script, by default, it is set to write the HKCU hive, which alters RAA on the exe file for the Current User only. If the script is set to change, say, the RAA flag for the Current User, it will not check if the flag is already set for All Users, causing the script to insist that Run as Admin is disabled when it is in fact enabled but for All Users instead.

The vice versa could happen, so make sure you have configured the script to change the correct Run as Admin setting you want (either HKCU, for the current user; or HKLM, for all users).

I don't know if I'm pandering too much, but *if you could change the script to skip UAC's while enabling the All Users RAA [...]
If enabling RAA for all users (i.e., editing a value in the HKLM hive), there will have to be some UAC dialogue somewhere (unless changing some permissions around in the HKLM hive is an option for you). Perhaps the UAC dialogue itself could be the indicator for whether a program is currently running-as-administrator-for-all-users or not. There's no easy way around UAC. We're going to have to work with it somehow.

I'm pushing harder here, but i'm hoping it turns into something maybe you yourself might even use! :D
But now that I think of it ..if you've gotten this far, is it possible to have 1 pop-up box after clicking "always admin", no matter whether the script is checking or unchecking the RAA box? With just a few exception: The pop-up comes after script as already done it's work instead of before, & it's contents of having your "Run as Admin is now Disabled[or Enabled]!" at the top perfectly like you made it, but with the words below that (yet above the buttons) instead of having, "Enable[or disable] run as admin comp setting?" with options "Yes, No, & Cancel", instead can it say "Continue or REVERSE changes?" with options in 2 boxes of "OK" or "Reverse"?.
Just a single popup indicator at the end, I guess, would speed the whole task up. But while what you describe could work for the Current User RAA setting, for All Users, it won't be so consistent. I'm not sure how this method would work out with the UAC dialogue in the way; there's just too many prompts.

Also, unfortunately the buttons on those boxes are predefined and are not customisable. All seven button layout types are documented here. And below is a demonstration of all the possible button layouts.
Code:
Set WshShell = CreateObject("WScript.Shell")

intSecondsWait = 8
strText = "Example text. Hello World."

For I = 0 To 6
	WshShell.Popup strText, intSeconds, "Popup no." & I + 1 & " of 7", I
Next

*Does running it as admin for All Users or not make any difference at all even if I'm the only user on the PC? I only am specifying toward the all-user run-as-admin box because I'm thinking it must cover all my bases. Or, for my purposes, would I not ever come across needing that specifically checked over the other "normal" run-as-admin properties box being checked? If there really is no difference, than no need to make any harrowing code tricks just to get the "ALL USER" version to check on/off. If so, & if it'd save you time, the other would be just fine.
You might have noticed, I am performing some ‘harrowing code trick’ just to get the All Users RAA option to work properly: I noticed that when configuring RAA for All Users programmatically (editing the registry directly), RAA wasn’t taking immediate effect. Have you noticed this when using the previous script in All Users mode?

So what I did, when setting RAA for All Users, it would also enable RAA for the Current User. The script would then make a RunOnce registry entry that removes the RAA option for the Current User next logon. RunOnce entries hold command lines that execute when the user logs in. Unfortunately, this method, which uses the Reg command, actually triggers a Command Prompt to flash briefly when logging in. I’ve now abandoned this RunOnce trick, in favour of a less fiddly method: taking advantage of the Startup folder to remove the RAA for the Current User.


Here's an update to the script. Popups happen after the doing has been done, but only for Current User RAA. You may modify the script to see what popups are like when they appear after the processing has been done for RAA All Users, but I warn, popups coming after in this setting don't look really pretty, so I've kept the popups here happening before. I'm just worried this inconsistency will take a hit on the script's intuitiveness.


ToggleRunAsAdmin_3.vbs
Code:
' ToggleRunAsAdmin_3.vbs ExeFile
' Toggles the "Run this program as an administrator" compatibility setting on 'ExeFile'.

Set WshShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set objReg = GetObject("WinMgmts:\\.\root\default:StdRegProv")

Function EnableRunAsAdmin(hDefKey, strSubKey, strValue, strData)
	objReg.SetStringValue hDefKey, strSubKey, strValue, strData
End Function

Function DisableRunAsAdmin(hDefKey, strSubKey, strValue, strData, ExistingData)
	If reLetters.Test( Replace(ExistingData, strData, "") ) Then
		If reRunAsAdmin.Test( ExistingData ) Then
			objReg.SetStringValue hDefKey, strSubKey, strValue, reRunAsAdmin.Replace(ExistingData, "")
		Else
			objReg.SetStringValue hDefKey, strSubKey, strValue, ExistingData & " " & strData
		End If
	Else
		objReg.DeleteValue hDefKey, strSubKey, strValue
	End If
End Function

Function DisblRaaScriptTemplateText()
	DisblRaaScriptTemplateText = "Const HKCU = &H80000001" & vbCrLf &_
		"Const HKLM = &H80000002" & vbCrLf & vbCrLf &_
		"Set objReg = GetObject(""WinMgmts:\\.\root\default:StdRegProv"")" & vbCrLf & vbCrLf &_
		"Set reLetters = New RegExp" & vbCrLf &_
		"reLetters.Pattern = ""[a-z]""" & vbCrLf &_
		"reLetters.IgnoreCase = True" & vbCrLf &_
		"reLetters.Global = True" & vbCrLf & vbCrLf &_
		"Set reRunAsAdmin = New RegExp" & vbCrLf &_
		"reRunAsAdmin.Pattern = "" *RUNASADMIN *""" & vbCrLf &_
		"reRunAsAdmin.IgnoreCase = True" & vbCrLf &_
		"reRunAsAdmin.Global = True" & vbCrLf & vbCrLf &_
		"Function DisableRunAsAdmin(hDefKey, strSubKey, strValue, strData, ExistingData)" & vbCrLf &_
		"	If reLetters.Test( Replace(ExistingData, strData, """") ) Then" & vbCrLf &_
		"		If reRunAsAdmin.Test( ExistingData ) Then" & vbCrLf &_
		"			objReg.SetStringValue hDefKey, strSubKey, strValue, reRunAsAdmin.Replace(ExistingData, """")" & vbCrLf &_
		"		Else" & vbCrLf &_
		"			objReg.SetStringValue hDefKey, strSubKey, strValue, ExistingData & "" "" & strData" & vbCrLf &_
		"		End If" & vbCrLf &_
		"	Else" & vbCrLf &_
		"		objReg.DeleteValue hDefKey, strSubKey, strValue" & vbCrLf &_
		"	End If" & vbCrLf &_
		"End Function" & vbCrLf & vbCrLf
End Function

If WScript.Arguments.Unnamed.Count = 0 Then WScript.Quit 1
If WScript.Arguments.Item(0) = "" Then WScript.Quit 1

Const StopIcon     = 16
Const QuestionIcon = 32
Const ExclamationIcon = 48
Const InformationIcon = 64

Const YesNoCancelButtons = 3
Const YesNoButtons		 = 4

dblWaitSeconds = -1.0 'Seconds popup boxes should wait before defaulting to 'no'. Specify negative number for infinite time. 

Const HKCU = &H80000001 'HKEY_CURRENT_USER
Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE

hDefKey	  = HKCU 'Use HKCU (for current user only) or HKLM (for all users)
strSubKey = "Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"
strValue  = WScript.Arguments.Item(0)
strData	  = "RUNASADMIN"

strStartupFolder = WshShell.ExpandEnvironmentStrings("%AppData%\Microsoft\Windows\Start Menu\Programs\Startup")

strRandomScriptFileName = fso.GetBaseName(WScript.ScriptFullName) & "_" & fso.GetTempName() & "_" & ".vbs"
strRandomScriptFile     = WshShell.ExpandEnvironmentStrings("%Temp%\" & strRandomScriptFileName)

Set reLetters = New RegExp
reLetters.Pattern    = "[a-z]"
reLetters.IgnoreCase = True
reLetters.Global     = True

Set reRunAsAdmin = New RegExp
reRunAsAdmin.Pattern    = " *RUNASADMIN *"
reRunAsAdmin.IgnoreCase = True
reRunAsAdmin.Global     = True

objReg.GetStringValue hDefKey, strSubKey, strValue, ExistingData
If IsNull(ExistingData) Then
	If hDefKey = HKLM Then
		intSelection = WshShell.Popup("The Run as Administrator compatibility setting for this executable is currently disabled." & vbCrLf & vbCrLf & "Would you like to enable this setting?", sngWaitSeconds, "Run as Administrator is Currently Disabled", QuestionIcon + YesNoButtons)
		
		Function EnableRaaHklm()
			Set fsoTextFile = fso.CreateTextFile(strRandomScriptFile)
			fsoTextFile.Write "Const HKCU = &H80000001" & vbCrLf
			fsoTextFile.Write "Const HKLM = &H80000002" & vbCrLf & vbCrLf
			fsoTextFile.Write "Set objReg = GetObject(""WinMgmts:\\.\root\default:StdRegProv"")" & vbCrLf & vbCrLf
			fsoTextFile.Write "objReg.SetStringValue HKCU, """ & strSubKey & """, """ & strValue & """, """ & strData & """" & vbCrLf
			fsoTextFile.Write "objReg.SetStringValue HKLM, """ & strSubKey & """, """ & strValue & """, """ & strData & """"
			fsoTextFile.Close
			WScript.Sleep 120
			CreateObject("Shell.Application").ShellExecute "WScript", strRandomScriptFile, "", "RunAs", 1
			WScript.Sleep 120
			fso.DeleteFile strRandomScriptFile
			
			objReg.GetStringValue HKLM, strSubKey, strValue, ExistingData
			If IsNull(ExistingData) = False Then
			Set fsoTextFile = fso.CreateTextFile(strStartupFolder & "\" & strRandomScriptFileName)
				fsoTextFile.Write DisblRaaScriptTemplateText()
				fsoTextFile.Write "DisableRunAsAdmin HKCU, """ & strSubKey & """, """ & strValue & """, """ & strData & """, """ & ExistingData & """" & vbCrLf
				fsoTextFile.Write "CreateObject(""Scripting.FileSystemObject"").DeleteFile WScript.ScriptFullName"
				fsoTextFile.Close
			End If
		End Function
		If intSelection = 6 Then EnableRaaHklm()
	Else
		EnableRunAsAdmin HKCU, strSubKey, strValue, strData

		intSelection = WshShell.Popup("This executable's Run as Administrator compatibility setting for the current user is now ENABLED." & vbCrLf & vbCrLf & "Would you like to disable this setting?", sngWaitSeconds, "Run as Administrator is now ENABLED", QuestionIcon + YesNoButtons)
		If intSelection = 6 Then DisableRunAsAdmin HKCU, strSubKey, strValue, strData, ExistingData
	End If
Else
	If hDefKey = HKLM Then
		intSelection = WshShell.Popup("The Run as Administrator compatibility setting for this executable is currently enabled." & vbCrLf & vbCrLf & "Would you like to disable this setting?", sngWaitSeconds, "Run as Administrator is Currently Enabled", ExclamationIcon + YesNoButtons)
		
		Function DisableRaaHklm()
			Set fsoTextFile = fso.CreateTextFile(strRandomScriptFile)
			fsoTextFile.Write DisblRaaScriptTemplateText()
			fsoTextFile.Write "DisableRunAsAdmin HKCU, """ & strSubKey & """, """ & strValue & """, """ & strData & """, """ & ExistingData & """" & vbCrLf
			fsoTextFile.Write "DisableRunAsAdmin HKLM, """ & strSubKey & """, """ & strValue & """, """ & strData & """, """ & ExistingData & """" & vbCrLf
			fsoTextFile.Close
			WScript.Sleep 120
			CreateObject("Shell.Application").ShellExecute "WScript", strRandomScriptFile, "", "RunAs", 1
			WScript.Sleep 120
			fso.DeleteFile strRandomScriptFile
			
			objReg.GetStringValue HKLM, strSubKey, strValue, ExistingData
			If IsNull(ExistingData) = True Then
				Set reRandomScriptFile = New RegExp
				reRandomScriptFile.Pattern = fso.GetBaseName(WScript.ScriptFullName) & "_rad.....\.tmp_\.vbs"
				reRandomScriptFile.IgnoreCase = True
				reRandomScriptFile.Global = True
				For Each File In fso.GetFolder(strStartupFolder).Files
					If reRandomScriptFile.Test(File.Name) Then
							fso.DeleteFile File.Path
					End If
				Next
			End If
		End Function
		
		If intSelection = 6 Then DisableRaaHklm()
	Else
		DisableRunAsAdmin HKCU, strSubKey, strValue, strData, ExistingData
		
		intSelection = WshShell.Popup("This executable's Run as Administrator compatibility setting for the current user is now DISABLED." & vbCrLf & vbCrLf & "Would you like to enable this setting?", sngWaitSeconds, "Run as Administrator is now DISABLED", ExclamationIcon + YesNoButtons)
		If intSelection = 6 Then EnableRunAsAdmin HKCU, strSubKey, strValue, strData
	End If
End If
 

My Computer My Computer

At a glance

Windows 10, Windows 8.1 Pro, Windows 7 Profes...
Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
Great Scot! You've done it again!

You've outdone yourself this time sir! It's perfreakin-perfect. Not that I don't admire your "harrowing coding", because I definitely do, for the RAA for all users, that was quite amazing. Especially giving me the tip to avoid UAC if I so chose by editing the registry permissions. BUT, your current version works so good, & well enough I'm just going to use it for the current user. I came to the conclusion that it shouldn't really matter, right? I'm the only user, I just wanted to be safe, in case some program wanted to run as something else besides my current User, which should probably never happen. I feel bad now though that I'm using it only for current user. Though you'll probably tell me I shouldn't, tho I do cuz this definitely helped me a ton & I learned a lot! The only thing I went in and changed in the script were the words "enable/disable" at the end with the question mark, because it could possibly confuse me if i were in a hurry & changed it to "reverse" so I'd be extra sure about the first sentence & since like you tought me, only certain button text is available. I hope that didn't mess anything up. Going into the script I do see your handy work & it is, again, quite amazing. You deserve way more reputation & thank points than what you got for this thread, & believe me I tried giving it to ya.

You might have noticed, I am performing some ‘harrowing code trick’ just to get the All Users RAA option to work properly: I noticed that when configuring RAA for All Users programmatically (editing the registry directly), RAA wasn’t taking immediate effect. Have you noticed this when using the previous script in All Users mode?
I did not notice this. I actually had left it the way it was with your last post until just visiting again because I was pretty sure you'd be a perfectionist & low and be hold, it is god-damned perfect. If at one point in the far future when my hard drive dies & this is all lost, I really believe there's a script heaven where this will go & live a happy eternity, because that's the least it deserves! lol
If you're talking about the script before that one, than I had not noticed it, it always worked instantly as far as I knew.

I kid you not when I say, this is a dream come true & perfection. I'm surprised how well you understood what I was asking for & even with my babbling you saw where I was coming from & took the time to make my request a reality. On top of all that being beyond patient with my late responses. You on the other hand were perfectly on top in response. So thanks again!!

^____________________________________________^
:party::party::party::party::party:
 

My Computer My Computer

At a glance

Windows 7 ultimate x64AMD Phenom II X4 B506144 MBytes DDR2AMD Radeon HD 7800 Series
Computer type
PC/Desktop
OS
Windows 7 ultimate x64
CPU
AMD Phenom II X4 B50
Motherboard
Gigabyte GA-MA790X-UD4P
Memory
6144 MBytes DDR2
Graphics Card(s)
AMD Radeon HD 7800 Series
Sound Card
High Definition Audio Device
Screen Resolution
1600X1200
Hard Drives
SAMSUNG HD502HJ ATA Device 465 GB
OCZ-ARC100 SSD Drive 111 GB
Mouse
AlienWare
Back
Top