Solved

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

Posted on 2013-01-07
6
1,702 Views
Last Modified: 2013-01-16
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
Comment
Question by:icecom4
  • 4
  • 2
6 Comments
 
LVL 54

Expert Comment

by:McKnife
ID: 38752363
Comment deleted as it requires further testing, sorry.
0
 

Author Comment

by:icecom4
ID: 38752983
I wonder if you are scratching your head like I am?
0
 
LVL 54

Accepted Solution

by:
McKnife earned 500 total points
ID: 38753112
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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:icecom4
ID: 38755427
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
 

Assisted Solution

by:icecom4
icecom4 earned 0 total points
ID: 38769256
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
 

Author Closing Comment

by:icecom4
ID: 38782029
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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you use NetMotion Mobility on your PC and plan to upgrade to Windows 10, it may not work unless you take these steps.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question