Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account



Photo

Problem with basic SfX script

- - - - -

  • Please log in to reply
6 replies to this topic

#1
Alystinn

Alystinn
  • Member
  • 3 posts
  • Joined 18-December 11
  • OS:Windows 7 x64
  • Country: Country Flag

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.cmd
echo.
echo ========================
echo  Get oracle Homes:
echo ========================
echo.
set KEY_NAME1=HKLM\SOFTWARE\ORACLE\KEY_OraDb11g_home1
set 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 SFX

Setup=Install.cmd
TempMode
Silent=1
Overwrite=1
Title=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 !! :)

 

 




How to remove advertisement from MSFN

#2
jaclaz

jaclaz

    The Finder

  • Developer
  • 15,017 posts
  • Joined 23-July 04
  • OS:none specified
  • Country: Country Flag

 

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



#3
Alystinn

Alystinn
  • Member
  • 3 posts
  • Joined 18-December 11
  • OS:Windows 7 x64
  • Country: Country Flag

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 !



#4
jaclaz

jaclaz

    The Finder

  • Developer
  • 15,017 posts
  • Joined 23-July 04
  • OS:none specified
  • Country: Country Flag

It's not that you have to explicit SETLOCAL ENABLEEXTENSIONS ? :unsure:

http://www.robvander...e.com/local.php

http://www.robvander...e.com/ntfor.php

 

jaclaz



#5
Yzöwl

Yzöwl

    Wise Owl

  • Super Moderator
  • 4,589 posts
  • Joined 13-October 04
  • OS:Windows 7 x64
  • Country: Country Flag

Donator

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 OFF
SETLOCAL ENABLEEXTENSIONS DISABLEDELAYEDEXPANSION
SET "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


#6
Alystinn

Alystinn
  • Member
  • 3 posts
  • Joined 18-December 11
  • OS:Windows 7 x64
  • Country: Country Flag

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=%%j
echo.							>%TEMP%\install.log
echo ========================	>>%TEMP%\install.log
echo Get oracle Homes:			>>%TEMP%\install.log
echo ========================	>>%TEMP%\install.log
echo.							>>%TEMP%\install.log
::
set KEY_NAME1=HKLM\SOFTWARE\ORACLE\KEY_OraDb11g_home1
set 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 ! :}



#7
submix8c

submix8c

    Inconceivable!

  • Patrons
  • 4,470 posts
  • Joined 14-September 05
  • OS:none specified
  • Country: Country Flag

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/...r-sfx-commands/

http://www.msfn.org/...setup-programs/


Edited by submix8c, 29 January 2015 - 01:26 AM.

Someday the tyrants will be unthroned... Jason "Jay" Chasteen; RIP, bro!

Posted Image





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users