Alystinn Posted January 26, 2015 Posted January 26, 2015 Hi eveybody,First sorry for my English, I'm FrenchI just try to create a basic SFX archive with software like 7zip SFX Maker or WinRAR. This script just run the following Windows batch (install.cmd) :@echo off:: Install.cmdecho.echo ========================echo Get oracle Homes:echo ========================echo.set KEY_NAME1=HKLM\SOFTWARE\ORACLE\KEY_OraDb11g_home1set VALUE_NAME1=ORACLE_HOME::FOR /F "tokens=3" %%a IN ('REG QUERY %KEY_NAME1% /v %VALUE_NAME1%') DO (set O-HOME=%%a)echo %O-HOME%::pause::::exitThe SFX parameters are :;Le commentaire ci-dessous contient des commandes pour script SFXSetup=Install.cmdTempModeSilent=1Overwrite=1Title=DG SetupAnd when I run the SfX file, the batch did not run properly and I have an error message, but if I run the batch manually it works like a charm!Think something is wrong in my SFX setup but I have no idea, could you please help !!
jaclaz Posted January 26, 2015 Posted January 26, 2015 And when I run the SfX file, the batch did not run properly and I have an error message, but if I run the batch manually it works like a charm!Think something is wrong in my SFX setup but I have no idea, could you please help !! Which "error message"?Does it come from the SFX engine or from the batch/command processor? jaclaz
Alystinn Posted January 26, 2015 Author Posted January 26, 2015 From the reg query in the batch ("ERROR: The system was unable to find te specified registry key or value")But the reg key actually exists !
jaclaz Posted January 26, 2015 Posted January 26, 2015 It's not that you have to explicit SETLOCAL ENABLEEXTENSIONS ? http://www.robvanderwoude.com/local.phphttp://www.robvanderwoude.com/ntfor.php jaclaz
Yzöwl Posted January 26, 2015 Posted January 26, 2015 How about also providing us with the full batch file! …echoing the data value of a registry key isn't an installation routine; and echo isn't a viable option when the script is being run silently? Additionally, I would make sure that you have no additional spaces in your variables and to be safe I'd make sure that the unknown data value is not broken by unexpected spaces too.@ECHO OFFSETLOCAL ENABLEEXTENSIONS DISABLEDELAYEDEXPANSIONSET "KEY_NAME1=HKLM\SOFTWARE\ORACLE\KEY_OraDb11g_home1"SET "VALUE_NAME1=ORACLE_HOME"SET "O-HOME="FOR /F "TOKENS=2*" %%a IN ('REG QUERY %KEY_NAME1% /V %VALUE_NAME1% 2^>NUL') DO SET "O-HOME=%%b"IF DEFINED O-HOME (ECHO=%O-HOME%) ELSE (ECHO=ERROR RETURNING REGISTRY KEY VALUE)PAUSE
Alystinn Posted January 28, 2015 Author Posted January 28, 2015 Thanks for your answers.Here is the script :@echo off:: ===========================================================================:: Install script:: =========================================================================== mode con: cols=130 TITLE Install Script for /F "delims=" %%j in ('cd') do set CURRDIR=%%jecho. >%TEMP%\install.logecho ======================== >>%TEMP%\install.logecho Get oracle Homes: >>%TEMP%\install.logecho ======================== >>%TEMP%\install.logecho. >>%TEMP%\install.log::set KEY_NAME1=HKLM\SOFTWARE\ORACLE\KEY_OraDb11g_home1set VALUE_NAME1=ORACLE_HOME::FOR /F "tokens=1-3" %%A IN ('REG QUERY %KEY_NAME1% /v %VALUE_NAME1% 2^>nul') DO ( set O-HOME=%%C)if defined O-HOME ( @echo Database Home is: %O-HOME% >>%temp%\install.log) else ( @echo %KEY_NAME1%\%VALUE_NAME1% not found.)::::pause::::exit@Yzöwl :I try yours and it works fine...but not from SfX archive, and it's the main problem: I want that batch to be run after the SfX extraction. I just noticed something, when the REG QUERY is applied on a key which contains spaces (ex: REG QUERY "HKLM\Software\Microsoft\Internet Explorer" /V "Version"), the batch works. Don't know if it can helps !
submix8c Posted January 29, 2015 Posted January 29, 2015 (edited) That's because you have the string wrapped in "quo tes" (see what I did there?). You keep saying "but not from SFX". Which part of the CMD - *none* of it or some other part? You are aware that the files are unpacked into (eg) "TEMP/<RandomGeneratedFoldername>", right? IOW, the CMD may run, but if you reference anything else in the SFX you need to address that "generated" FolderPath. A couple of random topics -http://www.msfn.org/board/topic/34343-winrar-sfx-commands/http://www.msfn.org/board/topic/149278-sfx-archives-dont-wait-the-setup-programs/ Edited January 29, 2015 by submix8c
Alystinn Posted February 2, 2015 Author Posted February 2, 2015 (edited) I finally get the answer from StackOverflow website : http://stackoverflow.com/questions/25294855/7-zip-sfx-executable-doesnt-have-the-full-registry The reg.exe command must be followed with /reg:64 switch :@echo off:: ===========================================================================:: Install script:: =========================================================================== mode con: cols=130 TITLE Install Script for /F "delims=" %%j in ('cd') do set CURRDIR=%%jecho. >%TEMP%\install.logecho ======================== >>%TEMP%\install.logecho Get oracle Homes: >>%TEMP%\install.logecho ======================== >>%TEMP%\install.logecho. >>%TEMP%\install.log::set KEY_NAME1=HKLM\SOFTWARE\ORACLE\KEY_OraDb11g_home1set VALUE_NAME1=ORACLE_HOME::FOR /F "tokens=1-3" %%A IN ('REG QUERY %KEY_NAME1% /reg:64 /v %VALUE_NAME1% 2^>nul') DO ( set O-HOME=%%C)if defined O-HOME ( @echo Database Home is: %O-HOME% >>%temp%\install.log) else ( @echo %KEY_NAME1%\%VALUE_NAME1% not found.)::::pause::::exitThanks for your helps anyway Edited February 2, 2015 by Alystinn
Yzöwl Posted February 2, 2015 Posted February 2, 2015 That isn't what I'd call a solution! Do you know what happens with your above 'solution' if the end user isn't running 64bit architecture. If you knew your end users were using a 64bit system then you could have tried creating a 64bit SFX, (WinRAR uses 32bit modules by default), by selecting the Default64.SFX or Zip64.SFX modules.
submix8c Posted February 2, 2015 Posted February 2, 2015 (heh...) Maybe the OP isn't using the 64-bit WinRar/7-Zip and/or doesn't understand that the package needs to target a specific X86/64 independently (no mix/match, choose one). Isn't that why all vendors (including MS) give two different packages? I won't swear to this, but I believe that the Winrar Key (if using Winrar) will work on either x86 -or- x64 version. Best bet is to use 7-Zip (free) and choose which Target they're going after. +1 Yzöwl
congnt92 Posted March 8, 2016 Posted March 8, 2016 (edited) Hi Yzöwl, submix8cI have same issue with Alystinn..I have a .bat and i want to convert it to test.exe which run on both 32 and 64bits OSIf i run test.bat then it work fine, but if i run test.exe then bat fail. Here my test.bat (file.tag put at system32 folder but test.exe return not found)@echo offif exist %windir%\system32\file.tag echo found! && pause && exitecho not found!pauseexitI'm using WinRAR 64bits trail version to make sfx .exe and I run .exe on 64bits OS.Can you give me some advices?Tks Edited March 8, 2016 by congnt92
submix8c Posted March 8, 2016 Posted March 8, 2016 (edited) Your EXE file (I assume the BAT is inside it) is being unpacked to a generated folder name inside your TEMP directory. Better take a closer look at the documentation for how to circumvent that. It'll be an additional parameter that you add in the "Text" window of the SFX. Trust me, the info is there. HTH Edited March 8, 2016 by submix8c 1
congnt92 Posted March 9, 2016 Posted March 9, 2016 Your EXE file (I assume the BAT is inside it) is being unpacked to a generated folder name inside your TEMP directory. Better take a closer look at the documentation for how to circumvent that. It'll be an additional parameter that you add in the "Text" window of the SFX. Trust me, the info is there. HTHTks for your reply, submix8cAfter some works, I found that: On windows 64bits, %windir%\system32 is C:\windows\system32 if run test.cmd. But it will be C:\windows\sysWOW64 folder if run test.sfx.exeSo after run test.sfx.exe and winrar call test.cmd, then test.cmd say that file.tag not found. May you will ask me: Why do you say that? Are you sure? Yes. I'm sure.Try with another test.cmd@echo offcopy C:\testfile.txt %windir%\system32\testfile.txtpausethen testfile.txt was copied to system32 folder. But if i create sfx exe by winrar, after test.cmd extract and run, it copy testfile.txt but to SysWow64 folder. So can you give me some hints how can I create sfx.exe that can be use on both 32 and 64bits.Tks.
jaclaz Posted March 9, 2016 Posted March 9, 2016 You need to detect if the running OS is 32 bit or 64 bit, then - when needed - use the "virtual" Sysnative folder:http://www.samlogic.net/articles/sysnative-folder-64-bit-windows.htm Of course while (AGAIN) you should use .cmd and not .bat as extension, how exactly you "convert" the batch file to an executable may matter. jaclaz 1
congnt92 Posted March 11, 2016 Posted March 11, 2016 You need to detect if the running OS is 32 bit or 64 bit, then - when needed - use the "virtual" Sysnative folder:http://www.samlogic.net/articles/sysnative-folder-64-bit-windows.htm Of course while (AGAIN) you should use .cmd and not .bat as extension, how exactly you "convert" the batch file to an executable may matter. jaclaz Hi Jaclaz,I'm sorry for delay response.I use .cmd extension as you say. And i use winrar to create sfx.exe. Right click test.cmd >> add to archive >> tick create sfx archive check box >> goto Advanced tab >> choose SFX optionspath to extract: %windir%run after extraction: test.cmdmode: hide alladvanced: admin accessupdate: overwrite all files. My goal is: I create a winpe by winbuilder and i must to make sure test.cmd only run in my winPE.In system32, i have a tag file to help me detect if winpe was build by me or others.So in test.cmd i have some command like: if exist %windir%\system32\file.tag then do something, or if exist %windir%\system32\myreg.reg then import it ....Because test.cmd required some extra files so i want to create sfx.exe that will extract to %windir% then excute it from here.But problem come from here, run test.cmd normally it work fine but if put it to sfx then it say that file.tag not found, mean it's running from winpe that not build by me even i'm testing on my pe.Tks.
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now