Batch, Registry & UAC

Page 1 of 2 12 LastLast

  1. Posts : 34
    Microsoft Windows 7 Ultimate (x64)
       #1

    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 Computer


  2. Posts : 1,289
       #2

    Propaganistas said:
    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 Computer


  3. Posts : 9,582
    Windows 8.1 Pro RTM x64
       #3

    Can you attach the file so that we can see how you've coded it?
      My Computer


  4. Posts : 34
    Microsoft Windows 7 Ultimate (x64)
    Thread Starter
       #4

    dmex said:
    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..

    Dwarf said:
    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
    Last edited by Propaganist; 05 Mar 2010 at 02:53.
      My Computer


  5. Posts : 34
    Microsoft Windows 7 Ultimate (x64)
    Thread Starter
       #5

    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 Computer


  6. Posts : 2,737
    Windows 7 Enterprise (x64); Windows Server 2008 R2 (x64)
       #6

    Do you have to have the BAT file create the REG file?
      My Computer


  7. Posts : 34
    Microsoft Windows 7 Ultimate (x64)
    Thread Starter
       #7

    WindowsStar said:
    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 Computer


  8. Posts : 34
    Microsoft Windows 7 Ultimate (x64)
    Thread Starter
       #8

    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 Computer


  9. Posts : 2,737
    Windows 7 Enterprise (x64); Windows Server 2008 R2 (x64)
       #9

    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 Computer


  10. Posts : 34
    Microsoft Windows 7 Ultimate (x64)
    Thread Starter
       #10

    WindowsStar said:
    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 Computer


 
Page 1 of 2 12 LastLast

  Related Discussions
Our Sites
Site Links
About 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 02:26.
Find Us