Jump to content

Problem with basic SfX script


Alystinn

Recommended Posts

Hi eveybody,

First sorry for my English, I'm French

I 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::::exit

The SFX parameters are :

;Le commentaire ci-dessous contient des commandes pour script SFXSetup=Install.cmdTempModeSilent=1Overwrite=1Title=DG Setup

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 !! :)

 

 

Link to comment
Share on other sites


 

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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 ! :}

Link to comment
Share on other sites

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 by submix8c
Link to comment
Share on other sites

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::::exit

Thanks for your helps anyway ;)

Edited by Alystinn
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

(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. :unsure:

 

Best bet is to use 7-Zip (free) and choose which Target they're going after.

 

+1 Yzöwl

Link to comment
Share on other sites

  • 1 year later...

Hi Yzöwl, submix8c

I 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 OS

If 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!pauseexit

I'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 by congnt92
Link to comment
Share on other sites

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 by submix8c
Link to comment
Share on other sites

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

Tks for your reply, submix8c

After 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.exe

So 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.txtpause

then 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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 options

path to extract: %windir%

run after extraction: test.cmd

mode: hide all

advanced: admin access

update: 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.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...