Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I can install the software by setting auto=1 in install.inf and then use the following script:

@echo off
for /F "tokens=2 delims=<>" %%i in ('type test.xml ^|find "<install>"') do (
set setup=%%i 
echo installing %installer% >>log.txt
%setup% 
)
@echo on 

XML config file (test.xml):

<?xml version="1.0" encoding="UTF-16"?>

<install>C:\Users\UIDW6331\Desktop\tcm801x64\INSTALL.EXE</install>
<install>C:\Users\UIDW6331\Desktop\tcm801x64\INSTALL.EXE</install>

The installation works, however, I want to install it in a specific destination directory. How can I do that?

Also, when I use switches like:

start /w %setup% /norestart /silent

or

%setup% /passive /norestart 

I get the following error:

The setup information file was not found. you need to unpack the whole archive before running the install.exe. installation aborted

How can this be fixed?

share|improve this question

1 Answer 1

I have no idea about your direct questions. But your batch file cannot work as written.

You cannot use %setup% in the same code block (FOR loop) that sets the value because the entire block is parsed in one pass, and the value is expanded before the parsing takes place. The value gets set properly, but the expanded value will be the value that existed before you entered your loop.

The first time you run your batch script, the setup variable is not yet defined, so it fails completely. The value gets set, but your loop cannot see it. Your script does not have setlocal, so the last value that was set is preserved when the script terminates. The next time you run your script, it will use the value preserved from the last run on each line of your XML file.

I believe you can fix this particular problem by substituting call %%setup%% for %setup%.

EDIT

Or better yet, simply eliminate the setup variable entirely and use %%i directly:

for /F "tokens=2 delims=<>" %%i in ('type test.xml ^|find "<install>"') do (
  echo installing %installer% >>log.txt
  %%i
)

Note - I don't understand where the installer value is coming from. I'm assuming you know what you are doing, but it looks odd to me.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.