Solved

Visual Studio Installer Custom Action VBS File copy config from installer dir to target dir

Posted on 2010-09-06
4
1,128 Views
Last Modified: 2013-11-27
Hi guys,
I'm creating a MSI setup with the Visual Studio Installer.

Its supposed to copy a config file that resides in the installer directory to the target directory.

I therefore created this VBS:
' Config file verschieben
dim fso, file
Set fso = CreateObject("Scripting.FileSystemObject")
fso.CopyFile WScript.Arguments(0), WScript.Arguments(1), true ' Installerdir\config, Targetdir, überschreiben
set fso = nothing

Open in new window



which works when run from CommandLine.

However, when I add a customaction and set its CustomActionData to
"[INSTALLDIR]\config" "[TARGETDIR]\"

I get an error message when running the setup.


What am I doing wrong? Is there an easier way to accomplish this?

I cannot add the config file to the setup project, since it's generated by a separate tool and added to the already compiled setup.
0
Comment
Question by:Scoox
  • 2
4 Comments
 
LVL 42

Expert Comment

by:sedgwick
ID: 33616349
in CustomActionData add:

/TARGETDIR="[TARGETDIR]\" /SOURCEDIR="[SOURCEDIR]\"

SOURCEDIR -> is where the .Msi installer located
TARGETDIR-> is the target installation directory of the .Msi installer

so basically, in your custom action dll, you run the script like this:

Process proc = Process.Start("cscript", string.Format("\"{0}\" \"{1}\"",
Path.Combine(Context.Parameters["SOURCEDIR"], "<ScriptName>.vbs"),  
Path.Combine(Context.Parameters["TARGETDIR"], "<ScriptName>.vbs")));
proc.WaitForExit();
0
 
LVL 1

Expert Comment

by:funazonki
ID: 33616785
If you have an installer project, you can just add the config file to the installer project's list of files and it will get delivered to the target directory at install time.
0
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 33617816
@funazonki -
i think Scoox said that he cannot add the config file to the setup project cause it is generated by separated tool.


@Scoox -
why not copy the config file via code from the custom action dll?
when you override OnInstall(), you can call:
File.Copy(
Path.Combine(Context.Parameters["SOURCEDIR"], "app.config"),
Path.Combine(Context.Parameters["TARGETDIR"], "app.config"), true);

which is simpler than doing it via script.

0
 

Author Closing Comment

by:Scoox
ID: 33619915
Thank you. I thought it would be hard to do it with custom dll. Can I write that in C#? Do you have a link for a tutorial?
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This video discusses moving either the default database or any database to a new volume.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now