You are not logged in.

#1 18 Dec 2015 13:58

hozza
Member
Registered: 05 Jul 2014
Posts: 27

Annoying problem with reg add

Okey! I have some code and it's converted to exe and that's is working just fine but,
when I add command REG ADD or REG IMPORT or anything related on REG it stops working!!
and be more specific it works until I convert it to exe!!!
what is the problem????

Offline

#2 18 Dec 2015 14:14

RG
Member
From: Minnesota
Registered: 18 Feb 2010
Posts: 362

Re: Annoying problem with reg add

With those few details and no code to view, my guess is that you have a 32/64 bitness problem. One is probably using the 32 bit version of the registry and the other is using the 64 bit version of the registry.
1. Are the machine(s) you are running on 32 or 64 bit?
2. Does it behave the same on both 32 & 64 bit machines?
3. On 64 bit machine try executing from both the 32 bit and 64 bit versions of CMD.exe and I suspect you will see the same problem with one of them.

To fix this on 64 bit machines add the appropriate option to your REG command /reg:32 & /reg:64 See REG QUERY /?


Windows Shell Scripting and InstallShield

Offline

#3 18 Dec 2015 15:12

hozza
Member
Registered: 05 Jul 2014
Posts: 27

Re: Annoying problem with reg add

Here is some of the test code this works fine if it is just bat file but when converted to exe it won't work anymore
my machine is 64bit (i tried that what you gues above but no luck!

@echo off
SETLOCAL
set found=
FOR /F "tokens=1-3 delims= " %%a IN ('REG QUERY "HKEY_CLASSES_ROOT\Applications\Somesoftware.exe\shell\open\command"') DO (
 set found=%%c
)

for /f "tokens=1-2" %%a in ("%found%") do (
 set mypath=%%~dpa
)

reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\My_Mods" /v DisplayName /t REG_SZ /d Test_name
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\My_Mods" /v DisplayVersion /t REG_SZ /d 1.22
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\My_Mods" /v InstallLocation /t REG_SZ /d %mypath%mods
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\My_Mods" /v NoModify /t REG_DWORD /d 1
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\My_Mods" /v Publisher /t REG_SZ /d MySelf
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\My_Mods" /v UninstallPath /t REG_SZ /d %mypath%mods\Uninstall.exe
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\My_Mods" /v UninstallString /t REG_SZ /d %mypath%mods\Uninstall.exe
Timeout 5
exit

Offline

#4 18 Dec 2015 16:33

bluesxman
Member
From: UK
Registered: 29 Dec 2006
Posts: 1,129

Re: Annoying problem with reg add

If this works as a script, and converting to exe is stopping it from doing so, one could assume that the conversion process is part of the problem.  This begs the question, why are you converting it to exe?


cmd | *sh | ruby | chef

Offline

#5 18 Dec 2015 16:59

foxidrive
Member
Registered: 04 Apr 2013
Posts: 339

Re: Annoying problem with reg add

Above the first "reg add" line put this and then run it compiled to see what it shows:

echo "%found%" "%mypath%"&pause

If that doesn't give you a clue then say how it fails to work too...

Offline

#6 18 Dec 2015 17:06

hozza
Member
Registered: 05 Jul 2014
Posts: 27

Re: Annoying problem with reg add

well shortly! main reason is that this is just a very small part of code and it holds lots of other files... i'm using this to convert http://www.battoexeconverter.com/

Offline

#7 18 Dec 2015 17:38

foxidrive
Member
Registered: 04 Apr 2013
Posts: 339

Re: Annoying problem with reg add

How does it fail?

Offline

#8 19 Dec 2015 10:26

hozza
Member
Registered: 05 Jul 2014
Posts: 27

Re: Annoying problem with reg add

foxidrive wrote:

How does it fail?

tested only that small part! and its working so I had to take some time to look that whole code,
and I did found reason why it was failing smile there was already one "set found=" , but noticed also
when converting to exe it does make entry to add/remove programs as it should do, but when
I look in actualy path in "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" there
is nothing!!!! there should be \My_Mods folder with keys but there is not!!!!

Offline

#9 20 Dec 2015 10:55

foxidrive
Member
Registered: 04 Apr 2013
Posts: 339

Re: Annoying problem with reg add

reg.exe might require more permissions

Offline

#10 20 Dec 2015 11:53

hozza
Member
Registered: 05 Jul 2014
Posts: 27

Re: Annoying problem with reg add

foxidrive wrote:

reg.exe might require more permissions

Yes I had to change it like this now its working but if you have better solution please feel free to modify!!!

@echo off
TITLE Searching Path
SETLOCAL
set found=
FOR /F "tokens=1-3 delims= " %%a IN ('REG QUERY "HKEY_CLASSES_ROOT\Applications\SomeSoftware.exe\shell\open\command"') DO (
 set found=%%c
)

for /f "tokens=1-2" %%a in ("%found%") do (
 set mypath=%%~dpa
)
Echo %mypath%
TITLE Adding Registry settings
Echo Windows Registry Editor Version 5.00 >>"%mypath%test_folder\regfile.reg"
Echo. >>"%mypath%test_folder\regfile.reg"
Echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\My_Mods] >>"%mypath%test_folder\regfile.reg"
Echo "UninstallPath"="%mypath%test_folder\Uninstall.exe" >>"%mypath%test_folder\regfile.reg"
Echo "UninstallString"="%mypath%test_folder\Uninstall.exe" >>"%mypath%test_folder\regfile.reg"
REG IMPORT "%mypath%test_folder\regfile.reg"

Last edited by hozza (20 Dec 2015 11:55)

Offline

#11 20 Dec 2015 14:48

foxidrive
Member
Registered: 04 Apr 2013
Posts: 339

Re: Annoying problem with reg add

hozza wrote:

please feel free to modify!!!

This isn't really better, but with your character set you can use this style of file creation.

@echo off
TITLE Searching Path
SETLOCAL
set found=
FOR /F "tokens=1-3 delims= " %%a IN ('REG QUERY "HKEY_CLASSES_ROOT\Applications\SomeSoftware.exe\shell\open\command"') DO (
 set found=%%c
)

for /f "tokens=1-2" %%a in ("%found%") do (
 set mypath=%%~dpa
)
Echo %mypath%
TITLE Adding Registry settings
(
Echo Windows Registry Editor Version 5.00
Echo(
Echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\My_Mods]
Echo "UninstallPath"="%mypath%test_folder\Uninstall.exe"
Echo "UninstallString"="%mypath%test_folder\Uninstall.exe"
)>"%mypath%test_folder\regfile.reg"
REG IMPORT "%mypath%test_folder\regfile.reg"
del "%mypath%test_folder\regfile.reg"

It also looks a lot like the second for loop can be eliminated -

Does this provide the variable you are after?

@echo off
FOR /F "tokens=1-3 delims= " %%a IN ('REG QUERY "HKEY_CLASSES_ROOT\Applications\SomeSoftware.exe\shell\open\command"') DO (
 set "mypath=%%~dpb"
)
Echo "%mypath%"
pause

Last edited by foxidrive (20 Dec 2015 14:49)

Offline

#12 20 Dec 2015 18:02

hozza
Member
Registered: 05 Jul 2014
Posts: 27

Re: Annoying problem with reg add

foxidrive wrote:

Does this provide the variable you are after?

@echo off
FOR /F "tokens=1-3 delims= " %%a IN ('REG QUERY "HKEY_CLASSES_ROOT\Applications\SomeSoftware.exe\shell\open\command"') DO (
 set "mypath=%%~dpb"
)
Echo "%mypath%"
pause

Yes it does!! and noticed later that there was a proplem with 64 and 32 bit system like RG wrote earlier but that also now corrected so now all working just fine!
although i try to get this code working for almost a week and I was going to rip hair of my head big_smile but as the saying goes All's Well That Ends Well cool

THANK YOU VERY MUCH: foxidrive and RG

Offline

Board footer

Powered by