Jump to content

[solved] How to use environment variables in .inf and .xml files?


radigast

Recommended Posts

I am trying to figure out how to use environment variables in .ini files and .xml files.

Specfically, I am trying to install Neat Image 5.8 onto the homedrive of any partition I choose. I have already successfully got Neat Image to silently install, but not to the correct drive. Here is a snippet from NeatImageInstall.inf. I have tried "%ProgramFiles%\Neat Image", but that did not work and was not correctly recognized. Any ideas?

NeatImageInstall.inf

   [Setup]
Lang=default
Dir=C:\Program Files\Neat Image"
Group=Neat Image
NoIcons=0

The same holds true for Adobe Photoshop CS3 Extended. I also want to install this on any homedrive of any partition I choose. Here is a snippet from deployment.xml.

Deployment.xml

   <?xml version="1.0" encoding="utf-8"?><Deployment>
<Properties>
<Property name="INSTALLDIR">C:\Program Files\Adobe</Property><Property name="installLanguage">en_US</Property></Properties>
<Payloads>
<Payload adobeCode="{F0699DAC-0DC4-410B-B558-6D8CB5F3511A}"><Action>install</Action></Payload></Payloads>
</Deployment>

Anyone succesfully get either of these 2 programs to recognize environment variables, like %ProgramFiles% or %systemdrive% ? And if so, how did you do it? I have the silent install working for both, so would like to avoid using AutoIt if possible.

Thanks!

Radigast

Edited by radigast
Link to comment
Share on other sites


I figured out the .inf using some AutoIT commands. The code below shows what AutoITcode I used to export the proper installation path into the needed NeatImageInstall.inf, and then run the install file. I am not a coder, so it probably isn't pretty...but at least it gets the job done.

NeatImageInstall.au3

  ; Delete Dir= section of .inf file
IniDelete ( "NeatImageInstall.inf", "Setup" , "Dir" )
; Rewrite Dir= section with environment variable install path
IniWrite("NeatImageInstall.inf", "Setup", "Dir", @ProgramFilesDir & "\Neat Image")
; Exectute Neat Image Setup
#include <Process.au3>
_RunDOS ("NeatSetup58D.exe /LOADINF=NeatImageInstall.inf /VERYSILENT")

However...environment variables in .xml files (particularly deployment.xml for Adobe Photoshop CS3) are still a mystery. Can anyone shed light on environment variables in .xml files??

--Radigast

Link to comment
Share on other sites

Well, there are not yet easy ways to alter xml files through commandline or autoit scripts. I use xmlstartlet to do the job. However this tool is not activily developed. Use the command option ed to edit/update xml files:

XMLStarlet Toolkit: Edit XML document(s)

Usage: xml ed <global-options> {<action>} [ <xml-file-or-uri> ... ]

where

<global-options> - global options for editing

<xml-file-or-uri> - input XML document file name/uri (stdin otherwise)

<global-options> are:

-P (or --pf) - preserve original formatting

-S (or --ps) - preserve non-significant spaces

-O (or --omit-decl) - omit XML declaration (<?xml ...?>)

-N <name>=<value> - predefine namespaces (name without 'xmlns:')

ex: xsql=urn:oracle-xsql

Multiple -N options are allowed.

-N options must be last global options.

--help or -h - display help

where <action>

-d or --delete <xpath>

-i or --insert <xpath> -t (--type) elem|text|attr -n <name> -v (--value) <valu

e>

-a or --append <xpath> -t (--type) elem|text|attr -n <name> -v (--value) <valu

e>

-s or --subnode <xpath> -t (--type) elem|text|attr -n <name> -v (--value) <val

ue>

-m or --move <xpath1> <xpath2>

-r or --rename <xpath1> -v <new-name>

-u or --update <xpath> -v (--value) <value>

-x (--expr) <xpath> (-x is not implemented yet)

XMLStarlet is a command line toolkit to query/edit/check/transform

XML documents (for more information see http://xmlstar.sourceforge.net/)

For example I use xmlstarlet to change FileZilla localdirectory path

xml ed -P -u "/FileZilla3/Servers/Server/LocalDir" -v "%USERPROFILE%\Websites" ".\settings\sitemanager.xml" > "%APPDATA%\FileZilla\sitemanager.xml"

Note xmlstarlet adds about 2MB to your install cd.

Edited by Acheron
Link to comment
Share on other sites

Thanks Acheron! That is exactly what I was looking for! You rock dude! I did some digging around in the help file and used your example to fudge my way into the right code.

Here are the steps I took to get Adobe Photoshop CS3 Extended slimmed down and fully functional onto any partition Windows is installed on. The Photoshop install went MUCH quicker, the Photoshop loads WAY faster, AND the total size on the CD was reduced from 478MB to 240MB! As a bonus, the notorious Bonjour service can be completely disabled after install and activation are complete.

Note: I opted out of the built-in silent install and used ScriptWriter to auto-create an AutoIT silent execuable for me. I could not figure out a way to make the silent install ONLY install the payloads I wanted. Also, I used WinRaR to extract everything to %Temp%\Photoshop, and Photoshop CS3 was installed to %ProgramFiles%\Adobe\. Change these paths to whatever you want!

Here is how I did it:

1. Use
to pre-configure (input serial, etc...) your Photoshop install, and figure out what payload folders are safe to delete from the initial setup folder. I kept only the payload folders specified, and Photoshop runs perfectly fine for me.

2. Download
to modify the Deploy.xml default installation variable. If you use the code below, your Photoshop CS3 will install to %ProgramFiles%\Adobe.

3. Place xml.exe into the $OEM$\$\system32 folder of your install cd.

4. Use the following code in a .cmd file to parse the installation directory in Deployment.xml. As noted, this will install Photoshop into %ProgramFiles%\Adobe. In the "xml" line of code, note how 2 different paths were used. The first is the location/name of your fresh, unmodified Deployment.xml file. The second is where you would like the modified Deployment.xml file. Also, in the next step, we will be creating an AutoIT file to silently install Photoshop CS3, so it is necessary to call that file in our batch script.

PhotoshopSilentInstall.cmd

:: Insterting %ProgramFiles%\Adobe Environment Install Path into Deployment.xml
xml ed -P -u "/Deployment/Properties/Property[@name='INSTALLDIR']" -v "%ProgramFiles%\Adobe" "%Temp%\Photoshop\Deployment.xml" > "%Temp%\Deployment.xml"

:: Overwriting old Deployment.xml with edited Deployment.xml
move /Y "%Temp%\Deployment.xml" "%Temp%\Photoshop\Deployment.xml"

:: Running AutoIT Silent Install Script
"PathToFile\YourAutoITScript.exe"

5. Use the
function ScriptWriter (
) to create a silent AutoIT script for you. Be sure to name it the same as you did in your batch file!

6. Put all the Photoshop files, your batchfile, and your newly-created AutoIT .exe file into the same folder and use a compression program to mush them into an .exe file. I used WinRaR. For my particular install, I used the following SFX Comments. Note how the batch file you created is being called by the SFX archive.

Path=%Temp%\Photoshop
SavePath
Setup="PhotoshopSilentInstall.cmd"
Silent=1
Overwrite=1

As soon as Photoshop is installed, the temp folder created will be automatically deleted, so no worries about cleanup!

7. After Photoshop is installed and activated, you can use
to download a super tiny .exe program that will automatically disable the Bonjour Service for you! It is called TurnOffBonour.exe.

To make this process completely silent, I used WPI to chain all the command installs so I didn't have to do a thing.

Enjoy your speedy, slimmed-down Photshop CS3.

I hope this all makes sense! I am not a coder in any way, and tend to use whatever resources I have availabe to me to make my life easy. There are probably easier ways to do what I did, but after posting on numerous forums (AutoIT, Adobe, MSFN) this is the solution that ended up working for me.

Cheers!

--radigast

Edited by radigast
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...