Avatar of icecom4
icecom4
Flag for United States of America asked on

batch will not execute if included with installer, or compiled into exe, or called from an exe

This seems odd to me and I am not sure what is causing it.  

I have a batch that adds the following registry string

reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v "%ProgramFiles%(x86)\bquest\bq.exe" /t REG_SZ /d "WINXPSP2 RUNASADMIN" /f >NUL

All it does it make the shortcut with admin privilages for the user.  

Problem:  This is one script among many in my larger batch file I will issue to my gaming community.  When compiled into exe it does not work.  If I make it a .bat it works, but if I call it from an exe file it does not work.  So I made an installer, which has the.bat as an include and launches it first before anything...and it does not work.  It only works as a bat file executed directly, nothing else can call on it.  

I have to get this working, it can be a .bat file i dont care, but it has to at least allow me to include it in the installer.  

What could cause this?  Some sort of windows permissions?
Shell ScriptingProgramming Languages-OtherScripting Languages

Avatar of undefined
Last Comment
cup

8/22/2022 - Mon
cup

Get procmon from Microsoft, run it up.  Run your installation.  See which part it is failing on.  It will tell you the call or the file it it trying to get to.  You can filter on processes to reduce the amount of output - procmon monitors all processes.
icecom4

ASKER
Maybe "will not execute" was poor choice of words.  If I pause the batch, then add to winrar, then execute, it says "the operation completed successfully" for each regedit line item.  Its just not there when I open registery.  So there is no error messages.  However it is there if I exec bat outside of the installer.  Bizarr, I will still try your utility when I get a chance later
cup

Is it asking for input, timing out and exiting incorrectly?
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
icecom4

ASKER
No to all.  In fact is seems to run normal.  It just does not edit the registry if compiled in winrar, or bat to exe.  Its got to have something to do with windows7.  I ran the .exe on windows xp and it works.  
I also tried not using batch at all, instead using .reg script, and the same thing happened.  

Is there something in windows 7 that would block a program from editing registry?
ASKER CERTIFIED SOLUTION
cup

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
cup

The other alternative is to tell the user to run the command manually with apologies that MS security won't allow you to do it automatically.  It is just another batch file and most users will be quite happy to do it.