Solved

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

Posted on 2013-01-07
6
1,716 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
How our DevOps Teams Maximize Uptime

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

 

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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Command prompt output to variable? 9 60
Script to write to a log file 18 43
Output in PHP throwing alignment of data off issue 12 45
Sony EVI-D70 and Skype 2 41
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

820 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