Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: REG ADD Batch  (Read 26299 times)

0 Members and 1 Guest are viewing this topic.

nothlit

    Topic Starter


    Intermediate

    Thanked: 2
    REG ADD Batch
    « on: October 23, 2010, 10:21:16 PM »
    In Windows 7 64 I can't seem to batch the command

    Code: [Select]
    regedit /s myregfile.reg
    It will act like it works but never imports anything when using a batch file. Taking out the /S and pressing YES to the import again acts like it is working but still nothing. Running the file manually or at run box does work so as far as I can tell this is related to Windows 7 or 64b and BATCH. In XP it works when in a batch file.

    My thought is use reg add which does appear to function and I believe it would be backwards compatible with wk2 and XP?

    ...but I can't get it to work exactly the way I want. I've tried many combinations but tired and frustrated not getting the right combination of switches etc. Here is what I have...

    Code: [Select]
    ECHO on

    reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v TrustedSites_SAO /t reg_sz /d "\"C:\Program Files\Silver A\SAO_FiservTrustedSites.exe\" /fromrunkey /f

    PAUSE

    /fromrunkey is my switch for the EXE that tells it is already installed to the registry. I'm not stuck on using "/fromrunkey" and have tried -fromrunkey" but I think with this switch for my program I'm losing the /f (force for reg add) if this is a reinstall. I'd rather it not prompt the user to overwrite and just do it. Plus this way in future if I need to update things I can.

    the exe is just a complied BAT file that is adding a couple trusted sites to internet explorer for the currently logged in user. This final part will make it run for every other  user.

    I'm half thinking I could do a REG DELETE if I can't get the /f (force switch) to work but again I'm trying to keep this somewhat simple to what I already have in place.

    Thanks for the help.

    nothlit

      Topic Starter


      Intermediate

      Thanked: 2
      Re: REG ADD Batch
      « Reply #1 on: October 23, 2010, 10:32:13 PM »
      Thinking this through and typing it out I'm thinking I'm going to just use reg delete first ... I think it will do what I want.


      Though if anyone knows why regedit /s *.reg file doesn't work let me know and feature net searchers ... I couldn't find it.

      Salmon Trout

      • Guest
      Re: REG ADD Batch
      « Reply #2 on: October 24, 2010, 02:09:19 AM »
      Though if anyone knows why regedit /s *.reg file doesn't work

      Batch file not being run as administrator? Regedit disabled by administrator?




      nothlit

        Topic Starter


        Intermediate

        Thanked: 2
        Re: REG ADD Batch
        « Reply #3 on: October 24, 2010, 04:53:36 PM »
        I think I may have found the issue to be related to the way I'm converting it to an EXE ... I'm thinking that windows is blocking the registry edit as in dos batch mode it does work after all. Might just have to keep it a cmd file instead of a EXE.

        Salmon Trout

        • Guest
        Re: REG ADD Batch
        « Reply #4 on: October 25, 2010, 12:11:22 AM »
        I think I may have found the issue to be related to the way I'm converting it to an EXE ... I'm thinking that windows is blocking the registry edit as in dos batch mode it does work after all. Might just have to keep it a cmd file instead of a EXE.

        You're using a virus creator batch-to-exe converter. Now you tell us!  ::)  ::) ::) ::) ::) Way to be an idiot  ::) ::) ::) Sounds like Windows 7 security is doing its job.

        These converters are a waste of time.




        nothlit

          Topic Starter


          Intermediate

          Thanked: 2
          Re: REG ADD Batch
          « Reply #5 on: October 25, 2010, 05:15:21 PM »
          Why do you say virus creator?

          I've used the process for a while when I need other files and such to go along with a batch file. Always seemed to work before.

          Are you saying that the process itself is a virus or that I'm using it to write viruses or something else?

          I did come across an article once regarding UPC.exe which sometimes flags as a virus in different antivirus products.



          ...as for being an idiot not trying to be. :P

          nothlit

            Topic Starter


            Intermediate

            Thanked: 2
            Re: REG ADD Batch
            « Reply #6 on: October 25, 2010, 05:23:28 PM »
            Apparently even this site ComputerHope has a download to the utility I am using...

            http://www.computerhope.com/dutil.htm

            Should I not use it? Again not trying to be an idiot but if you know something I don't etc let me know.



            I'm also aware of something windows 7 64 bit did with the kernel to protect it which again might be why going hand in hand with everything you have said might mean that the EXE version of the bat file isn't working.

            Anyway thanks for the help.

            nothlit

              Topic Starter


              Intermediate

              Thanked: 2
              Re: REG ADD Batch
              « Reply #7 on: October 26, 2010, 10:57:07 AM »
              What do you think about 7zip? ... http://www.gdgsoft.com/faq/7zsfx.htm

              I looks like I could use that to make a self installer and that is more so what I am looking for by using Bat 2 EXE ... a Way to keep things in a neat little package. I like bat 2 exe though because I can hide the window easily. The whole purpose of adding the registry entry to startup at run was to apply certain sites to Local Users Trusted Sites. And Enabled the Downloading of Signed Active X controls. For the most part in this case I can keep the file as a CMD ...

              But I have used Bat 2 Exe to create an installer package if you will that ended up being some 80 mb. I used it to automate a process from start to finish.

              Salmon Trout

              • Guest
              Re: REG ADD Batch
              « Reply #8 on: October 26, 2010, 11:15:01 AM »
              hide the window
              apply certain sites to Local Users Trusted Sites.
              Enabled the Downloading of Signed Active X controls

              Hmmm....

              nothlit

                Topic Starter


                Intermediate

                Thanked: 2
                Re: REG ADD Batch
                « Reply #9 on: October 26, 2010, 11:30:33 AM »
                Bah ... don't turn me in to a virus person ... this isn't about that.

                The purpose of this is for work and to stop clients from screwing up the initial staging of the PCs. It sets up the settings for there user and add itself to run when the next user logs in. I didn't want to put the code up but here it is. I'd still appreciate your input about the virus bat to exe utility. If you don't feel comfortable with that then so be it. I can see how you would think I'm writing a virus but as long as I have been on this site I have never asked anything like that before or even tried to create such an application before.

                Code: [Select]
                ECHO OFF
                CLS
                set runkey=%1
                if "%runkey%"=="" (
                set runkey=null
                ) ELSE (
                SET runkey=%runkey:"=%
                )
                set sb=%systemdrive%\Program Files\Silver

                if "%runkey%"=="/fromrunkey" (
                set silent=1
                ) ELSE (
                set silent=0
                REM silent zero is another way of saying first run or install to run key
                )

                CALL :REGadd
                if "%silent%"=="0" Call :CreateReg
                if "%silent%"=="0" ECHO. & ECHO Process Completed & PAUSE

                EXIT
                :REGadd

                if "%silent%"=="0" (
                CLS
                ECHO.
                ECHO This process will add *fiservsco.com to trusted sites.
                ECHO It will also auto define Enterprise SCO trusted site settings.
                ECHO.
                ECHO.
                PAUSE & CLS & ECHO.
                )
                :FiservscoTrustedSite
                if "%silent%"=="0" ECHO https://*.fiservsco.com added as trusted site
                >nul reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\fiservsco.com" /v https /t reg_dword /d 00000002 /f
                if "%silent%"=="0" ECHO https://10.206.*.*/ added as trusted site
                >nul reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range1" /v https /t reg_dword /d 00000002 /f
                >nul reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range1" /v :Range /t reg_sz /d 10.206.*.* /f
                ECHO. & ECHO.

                :TrustedSettings
                :DownloadSignedActiveXControls
                if "%silent%"=="0" ECHO Enable - Download Signed ActiveX Controls
                >nul reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2" /v 1001 /t reg_dword /d 00000000 /f

                :DownloadUnsignedActiveXControls
                if "%silent%"=="0" ECHO Prompt - Download Unsigned ActiveX Controls
                >nul reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2" /v 1004 /t reg_dword /d 00000001 /f

                :RunActiveXControlsAndPlugIns
                if "%silent%"=="0" ECHO Enable - Run ActiveX Controls and Plug-Ins
                >nul reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2" /v 1200 /t reg_dword /d 00000000 /f

                :InitializeAndScriptActiveXControlsNotMarkedAsSafe
                if "%silent%"=="0" ECHO Prompt - Initialize and Script ActiveX Controls Not Marked As Safe
                >nul reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2" /v 1201 /t reg_dword /d 00000001 /f

                :ActiveXControlsAndPlugInsAllowPreviouslyUnusedControlsWithoutPrompt
                if "%silent%"=="0" ECHO Enable - Allow Previously Unused controls without prompt
                >nul reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2" /v 1208 /t reg_dword /d 00000000 /f

                :ActiveXControlsAndPlugInsAllowScriptlets
                if "%silent%"=="0" ECHO Prompt - Allow Scriptlets
                >nul reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2" /v 1209 /t reg_dword /d 00000001 /f

                :AxtiveXControlsAndPlugInsScriptActiveXControlsMarkedAsSafeForScripting
                if "%silent%"=="0" ECHO Enable - ActiveX Controls Marked as Safe For Scripting
                >nul reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2" /v 1405 /t reg_dword /d 00000000 /f

                :PopUpBlocker
                if "%silent%"=="0" ECHO Disable - Popup Blocker
                >nul reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2" /v 1809 /t reg_dword /d 00000003 /f

                :ActiveXControlsAndPlugInsBinaryAndScriptBehaviours
                if "%silent%"=="0" ECHO Enable - Binary and Scripts Behaviours
                >nul reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2" /v 2000 /t reg_dword /d 00000000 /f

                :ActiveXControlsAndPlugInsActomaticPromptingForActiveXControls
                if "%silent%"=="0" ECHO Enable - Automatic Prompting for ActiveX Controls
                >nul reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2" /v 2201 /t reg_dword /d 00000000 /f

                :EncryptedSave
                if "%silent%"=="0" ECHO Enable - Do not save encrypted pages to disk
                >nul reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v DisableCachingOfSSLPages /t reg_dword /d 00000000 /f

                REM 0=enable
                REM 1=prompt
                REM 3=disable

                GOTO:EOF

                :CreateReg
                :: UAC stops below from running. Not be elevated stops from running.
                REM reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v TrustedSites_SCO /f
                REM reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v TrustedSites_SCO /t reg_sz /d "\"C:\Program Files\Silver\EnterpriseSCO_FiservTrustedSites.exe\" /fromrunkey

                set startupreg=%temp%\TrustedSites_SCO.reg

                ECHO Windows Registry Editor Version 5.00>%startupreg%
                Echo.>>%startupreg%
                ECHO [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]>>%startupreg%
                ECHO "TrustedSites_SCO"="\"%systemdrive%\\Program Files\\Silver\\EnterpriseSCO_FiservTrustedSites.bat\" /fromrunkey">>%startupreg%
                :: solution to above limitations is to use regedit /s as it causing Windows to prompt UAC for verification.
                regedit /S "%startupreg%"

                REM ping 127.0.0.1 -n 2 >nul
                GOTO:EOF

                BC_Programmer


                  Mastermind
                • Typing is no substitute for thinking.
                • Thanked: 1140
                  • Yes
                  • Yes
                  • BC-Programming.com
                • Certifications: List
                • Computer: Specs
                • Experience: Beginner
                • OS: Windows 11
                Re: REG ADD Batch
                « Reply #10 on: October 26, 2010, 12:23:57 PM »
                Apparently even this site ComputerHope has a download to the utility I am using...

                http://www.computerhope.com/dutil.htm

                Should I not use it? Again not trying to be an idiot but if you know something I don't etc let me know.

                That is a utility for converting documents... It's not a BAT to EXE converter.


                Quote
                I'm also aware of something windows 7 64 bit did with the kernel to protect it which again might be why going hand in hand with everything you have said might mean that the EXE version of the bat file isn't working.
                hate to break the news, but  the kernel has nearly nothing to do with it, really. There are a few "varieties" of EXE2BAT converters. Note that some misname themselves "compilers" but none of them are.


                The earliest variety converted PURE DOS batch files into COM executables. This only worked on very small batch files because the COM executable was really just a tiny stub that ran the BAT that was pasted onto the end of the COM file. These were 16-bit, and usually the compiler program had a simple parser that tried to "optimize" things, usually failing quite miserably.

                Another early variant was a "sort-of" compiler; it did convert the Batch into a true blue ASM file which you could assemble into an Object file which could then be linked into an executable. Later variants even made those steps automatic. However, no compiler of this sort works with anything but pure DOS commands. Also, they compile to 16-bit DOS executables.

                Nowadays, the only 32-bit "compiler" Batch programs that can be found are those that simply paste the batch file as a resource or on the end of a generic executable, which merely writes that resource to a temporary file and then runs it through the same command interpreter, and another variant which tries to hide it's shame by literally encrypting the batch file resource, so you can't see it as plain text if you open the resulting executable.

                of course, Process Monitor can see the resulting batch file in memory, and you can simply find the bat that was extracted by the stub executable anyway, so I'm not sure what the real point of those would be.

                The main problem with them, is- while you control the batch file, you really have no idea *censored* the stub program truly does. It could very well be sending some crazy usage data to some unrelated third party or it could really be a trojan downloader (seen examples of both). And truly it's never worth it to "compile" any batch file. Anybody who thinks so is fooling themselves.



                the batch you posted tells you the problem in the comment.

                Quote
                :: UAC stops below from running. Not be elevated stops from running.

                you can run a Batch file via UAC of course, but when you use a "batch 2 exe converter" it may very well be running the stub program as admin, and it should be running the batch file as admin as well, but bat2exe converters are notoriously poorly written and it's highly possible that the person who wrote it is retarded and therefore the batch file that is run by the stub program is not elevated at all, and it's impossible to get it to run elevated without changing the "stub" program.
                I was trying to dereference Null Pointers before it was cool.

                nothlit

                  Topic Starter


                  Intermediate

                  Thanked: 2
                  Re: REG ADD Batch
                  « Reply #11 on: October 26, 2010, 12:38:15 PM »
                  That is a utility for converting documents... It's not a BAT to EXE converter.
                   

                  Scroll down that page it is there...

                       DOS
                  File:   Bat_To_Exe_Converter.exe
                  Version:   1.4
                  Operating System:   Windows 95 and above.
                  Description:   Allows users to convert their batch files to executable files, allowing others not to see the source code and keep it hidden. See document CH000435 for additional details.
                  Installation Notes:   Extract file and run the executable.
                  File Size:   422 KB
                  Cost:   None
                  Download   Bat_To_Exe_Converter.zip

                  As far as the batch converter being poorly written, maybe ... as for the batch not being run in elevated status that would/could make some sense. I do know this particular converter does have an option to "Add Vista administrator manifest" which I use but then again this is windows 7 must better then Vista so maybe that is in part why it doesn't work.

                  The whole purpose of me using something like this is to keep things simple for end users. Take a simple batch file include a bunch of other files they would need into one tidy little package to run through an install. As far as it being a true complier ... I'm not really concerned with it hiding my original code, some clients want to know what is going on under the hood so it doesn't matter to me if they look at the original code that is being fired off.

                  Thank you for the History BC_Programmer, as always you are able to teach me something I didn't know.

                  nothlit

                    Topic Starter


                    Intermediate

                    Thanked: 2
                    Re: REG ADD Batch
                    « Reply #12 on: October 27, 2010, 06:37:17 PM »
                    Confused a bit more ... It looks like my EXE is working after all but instead of going to the hardcode registry key it is redirecting my reg file to this if in EXE mode ...


                    [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run]

                    If left as CMD it goes to what I would consider the normal global run without the Wow6432Node.


                    Would anyone know why?

                    Is it because the converter is 32bit and the OS is 64bit? Just trying to make sense of it. Thanks.

                    JJ 3000



                      Egghead
                    • Thanked: 237
                    • Experience: Familiar
                    • OS: Linux variant
                    Re: REG ADD Batch
                    « Reply #13 on: October 27, 2010, 06:56:31 PM »
                    However, no compiler of this sort works with anything but pure DOS commands. Also, they compile to 16-bit DOS executables.

                    That's seems like the problem. There is no 16 bit subsytem on 64 bit versions of windows.
                    Save a Life!
                    Adopt a homeless pet.
                    http://www.petfinder.com/

                    BC_Programmer


                      Mastermind
                    • Typing is no substitute for thinking.
                    • Thanked: 1140
                      • Yes
                      • Yes
                      • BC-Programming.com
                    • Certifications: List
                    • Computer: Specs
                    • Experience: Beginner
                    • OS: Windows 11
                    Re: REG ADD Batch
                    « Reply #14 on: October 27, 2010, 08:04:54 PM »
                    That's seems like the problem. There is no 16 bit subsytem on 64 bit versions of windows.

                    No. In this case the program runs without an error message, but doesn't work properly. That particular area of my post was more a history lesson then anything else; also, their batch uses parentheses blocks, which aren't valid in a Pure DOS Batch file anyway.
                    I was trying to dereference Null Pointers before it was cool.

                    Salmon Trout

                    • Guest
                    Re: REG ADD Batch
                    « Reply #15 on: October 28, 2010, 01:02:50 AM »
                    If left as CMD it goes to what I would consider the normal global run without the Wow6432Node.

                    Would anyone know why?

                    Is it because the converter is 32bit and the OS is 64bit? Just trying to make sense of it. Thanks.

                    You do know there are two cmd.exe versions present in 64 bit Windows? One 64 bit and one 32 bit?

                    64 bit... %windir%\system32\cmd.exe
                    32 bit... %windir%\SysWoW64\cmd.exe

                    Below you can see I go from 64 to 32 bit cmd and back again. You can see how to check the version...

                    Code: [Select]
                    C:\Users\Mike>%windir%\system32\cmd.exe
                    Microsoft Windows [Version 6.1.7600]
                    Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

                    C:\Users\Mike>echo %programfiles%
                    C:\Program Files

                    C:\Users\Mike>%windir%\syswow64\cmd.exe
                    Microsoft Windows [Version 6.1.7600]
                    Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

                    C:\Users\Mike>echo %programfiles%
                    C:\Program Files (x86)

                    C:\Users\Mike>exit

                    C:\Users\Mike>echo %programfiles%
                    C:\Program Files

                    http://www.tipandtrick.net/2008/how-to-open-and-run-32-bit-command-prompt-in-64-bit-x64-windows/


                    nothlit

                      Topic Starter


                      Intermediate

                      Thanked: 2
                      Re: REG ADD Batch
                      « Reply #16 on: October 29, 2010, 08:31:58 AM »
                      Thanks for that Salmon Trout. Good information, I had run across the separation before that windows had the two environments but during this whole thing I really didn't think about it. Live and learn I suppose.