Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Batch, Registry & UAC

04 Mar 2010   #1
Propaganist

Microsoft Windows 7 Ultimate (x64)
 
 
Batch, Registry & UAC

Hi all,

I've written a batch file which adds registry keys (with dynamic driveletter recognition) upon startup, launches a program and deletes the keys when closing the program.

My only concern now is that when launching the batch, I get a UAC dialog for the registry changes.

Is there some way I can tell Windows through the batch file that I really don't need any dialog (for this file only)?

I don't know anything about the creation process of EXEs, but I've never seen any UAC for registry changes made by EXEs...? So it has to be possible I guess...

Thanks!
Propa


My System SpecsSystem Spec
.
04 Mar 2010   #2
dmex

 

Quote   Quote: Originally Posted by Propaganistas View Post
Hi all,

I've written a batch file which adds registry keys (with dynamic driveletter recognition) upon startup, launches a program and deletes the keys when closing the program.

My only concern now is that when launching the batch, I get a UAC dialog for the registry changes.

Is there some way I can tell Windows through the batch file that I really don't need any dialog (for this file only)?

I don't know anything about the creation process of EXEs, but I've never seen any UAC for registry changes made by EXEs...? So it has to be possible I guess...

Thanks!
Propa
Hi Propa,

It depends where you write these keys, if your just using the HKCU (Current User) hive then you wont need UAC elevation, however every other hive will result in a UAC prompt

Steven
My System SpecsSystem Spec
04 Mar 2010   #3
Dwarf

Windows 8.1 Pro RTM x64
 
 

Can you attach the file so that we can see how you've coded it?
My System SpecsSystem Spec
.

04 Mar 2010   #4
Propaganist

Microsoft Windows 7 Ultimate (x64)
 
 

Quote   Quote: Originally Posted by dmex View Post
Hi Propa,

It depends where you write these keys, if your just using the HKCU (Current User) hive then you wont need UAC elevation, however every other hive will result in a UAC prompt

Steven
That's odd... The keys are all going in HKCU but I still get a dialog..

Quote   Quote: Originally Posted by Dwarf View Post
Can you attach the file so that we can see how you've coded it?
The file is my workaround for a highly portable Virtual DJ Installation. By running it through this batch, it enables me to run one single installation from usb on every possible computer.

Anyway, here you go.

(PS: I do have a valid license)

/EDIT: attachment removed
My System SpecsSystem Spec
05 Mar 2010   #5
Propaganist

Microsoft Windows 7 Ultimate (x64)
 
 

Ok. I got some sort of breakthrough...

If I run the batch as Administrator, none of the dialogs appear, but running cmd as Administrator also changes the initial working directory.

This is fixed by inserting cd /d %~dp0 to the very beginning of the file (or just after @echo off).

So now I don't have registry dialogs anymore, but I have to select Run as Administrator & confirm...

Any other ideas to completely hide all dialogs?
My System SpecsSystem Spec
05 Mar 2010   #6
WindowsStar

Windows 7 Enterprise (x64); Windows Server 2008 R2 (x64)
 
 

Do you have to have the BAT file create the REG file?
My System SpecsSystem Spec
05 Mar 2010   #7
Propaganist

Microsoft Windows 7 Ultimate (x64)
 
 

Quote   Quote: Originally Posted by WindowsStar View Post
Do you have to have the BAT file create the REG file?
Yes, the bat file catches the working driveletter, which is necessary for the registry keys.
My System SpecsSystem Spec
05 Mar 2010   #8
Propaganist

Microsoft Windows 7 Ultimate (x64)
 
 

Got it!

Instead of calling REGEDIT, I need to call REG(.exe), which doesn't interfere with UAC.

So

Code:
START /WAIT REGEDIT /S
becomes

Code:
REG IMPORT
My System SpecsSystem Spec
05 Mar 2010   #9
WindowsStar

Windows 7 Enterprise (x64); Windows Server 2008 R2 (x64)
 
 

Ok I understand now. Yes there is a way to make it work transparent however the Batch would need to be converted to VBScript. It would take a bit of time to convert it and then add the extra code to make it work as you need it. I have a lot of the code already written (saved somewhere, I need to look for it).

I don't have the time tonight to re-write it and then I don't have the means to test it. Maybe if no-one here comes up with a better idea I can look at it over the weekend. I will keep re-viewing this thread.
My System SpecsSystem Spec
05 Mar 2010   #10
Propaganist

Microsoft Windows 7 Ultimate (x64)
 
 

Quote   Quote: Originally Posted by WindowsStar View Post
Ok I understand now. Yes there is a way to make it work transparent however the Batch would need to be converted to VBScript. It would take a bit of time to convert it and then add the extra code to make it work as you need it. I have a lot of the code already written (saved somewhere, I need to look for it).

I don't have the time tonight to re-write it and then I don't have the means to test it. Maybe if no-one here comes up with a better idea I can look at it over the weekend. I will keep re-viewing this thread.
Got it already. See my previous post.
My System SpecsSystem Spec
Reply

 Batch, Registry & UAC




Thread Tools




Similar help and support threads
Thread Forum
Problem with batch file command to edit registry
reg add HTLM\Software\Microsoft\Windows\CurrentVersion\Policies\System /v DontDisplayLastUserName /t REG_DWORD 00000001 /f I am trying to hide all users at logon and I know this is where you change it but for some odd reason the syntax is wrong and I can not figure it out. Can someone please...
Customization
removing batch file from registry
recently I ran Mamu's add icons to system batch file for mame icons. I wasn't satified with the results so I was going to do a system restore. Then I learned system restore was turned off "which I turn off when I defrag then turn back on when completed". Now I can't figuere out how to remove it....
Software
How to run a batch file at logoff & some batch scripting help please
Hiya, I'd just like to run a simple batch file at logoff to backup some settings. I plan to use Robocopy, which is what i use to more thorough backups. Two questions: 1. How make it run by clicking Start > Shutdown? (i realise i could make a shutdown batch file and run it instead, but i'd...
Backup and Restore
How do i capture a folder of registry keys and make then a exe batch?
I'm modifying an old game.. including patches, and modifications. I want to make my own installer using WinRar but WinRar doesn't do registry keys. I thought I'd make a self executing batch file with all my needed registry keys and point WinRar to that during install. I heard this was possible but...
General Discussion
Deleting registry keys with a batch file?
I downloaded a beta version of a program and it for some reason it has a "usage count" in the registry which denies access to the program after 10 uses. When i delete the key it works again but it's pretty annoying to keep deleting it through the registry all the time. I want to make a batch...
General Discussion
Batch editing of Registry
I want to edit my registry to remove EVERY reference to a program which I have uninstalled, but which still has dozens (or more) of references still embedded in the registry. Is there a registry editor in which I can enter one single word, and the editor will search out every mention of that...
Software


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 03:30.
Twitter Facebook Google+ Seven Forums iOS App Seven Forums Android App