Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1845
  • Last Modified:

flag file to run as admin in registry (windows 8)

The below registry edit from batch does update the registry, however the file "test.bat" does not flag "run as administrator".

I used this in windows XP and Windows 7 and it works, not sure why it does not work in Windows 8.  

Is there a different path in Windows 8 to perform this task other than AppCompatFlags\Layers?

REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v "%systemdrive%\program files\TEST\program\Test.bat" /t REG_SZ /d "WINXPSP2 RUNASADMIN" /f >nul 2>nul
0
icecom4
Asked:
icecom4
  • 4
  • 2
2 Solutions
 
McKnifeCommented:
Comment deleted as it requires further testing, sorry.
0
 
icecom4Author Commented:
I wonder if you are scratching your head like I am?
0
 
McKnifeCommented:
Yeah, scratched it throughly.

First, in win8, it's "~ RUNASADMIN"
but that's not enough and I don't know why.

Set it manually (via the compatibility tab), works. Used another program and this time did a registry comparison using regshot - I did not see a difference but the aforementioned key, so that seemed to be it, but it ain't. Setting that key manually does not produce the same result.

if I were you, I would do a file and registry before and after comparison. Use wininstall LE (Freeware) to do it. wininstall LE produces an MSI file that can be further analysed to reveal all file and reg changes.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
icecom4Author Commented:
yes, this is weird, by adding a registry flag makes things worse for the bat file.  Without the key, it will not run as admin, but with the key, it go bonkers and starts echoing everything in the batch, and will not execute or close.
0
 
icecom4Author Commented:
I decided to use a vbscript to edit the shortcuts, something in windows 8 is not allowing the registry to FULLY control the file.  

I found the solution on this page...
http://stackoverflow.com/questions/6652486/how-to-set-run-as-administrator-flag-on-shortcut-created-by-msi-installer

However your post about "~ RUNASADMIN" actually led me to it.  

So thanks!
0
 
icecom4Author Commented:
Windows 8 will not fully flag a .lnk file properly in the registry, it makes links to batch scripts behave crazy.  the best way is to use a vbscript to flag runasadmin outside of the registry.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now