I finished my software and I'm not able to find a correct way to create its setup.
I searched the web and here but I found only old post referring old visual studio versions.
As I know in VS 2013 community edition I have a limited Installshield plugin and I was able to download the Visual Studio Installer plugin too. To create a simple setup is relatively easy but I need to silent install a small software during my setup. The software is Double Agent (an updated version of the Microsoft Agent) and the developer recommend to launch the setup in this way:
Simply run:
msiexec /i DoubleAgent_x86.msi /qb-!
during your setup (i think the best place should be the Commit event).
By the way it's not possible to launch .msi installer with an action and I really don't understand the best practice to create a custom action.
I read something about to create a class but most articles refer to Visual Studio 2008 or to Wix plugin. I'm searching a way to use Msiexec with Visual Studio Installer or installshield.
Edit: I found this solution and it works so good: https://msdn.microsoft.com/it-it/library/vstudio/d9k65z2d%28v=vs.100%29.aspx
It's in Italian but it's easy to translate to the original language (English) with the top right radio button. It's working perfectly with Visual Studio Setup plugin and VS Community edition 2013.
I have no code to post at this time because I built only their sample but I will post it asap with the usage of msiexec for the hidden installation.
I created a test winform project, I added the installer class with this code:
[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
public override void Commit(IDictionary savedState)
{
base.Commit(savedState);
// Use ProcessStartInfo class
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.FileName = "msiexec.exe";
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.Arguments = "/i DoubleAgent.msi /qb-!";
try
{
// Start the process with the info we specified.
// Call WaitForExit and then the using statement will close.
using (Process exeProcess = Process.Start(startInfo))
{
exeProcess.WaitForExit();
}
}
catch
{
// Log error.
}
}
And I created the setup with Visual Studio installer. At the end of the main setup something start saying there is another installation but the double agent does not install.
Edit again: I have not Admin right to execute msiexec silently. I think because the Double Agent setup need admin rights. I don't want to use manifest to elevate privileges then I think the only solution is to show the DoubleAgent installer (also if in minimal output).
By the way I have this code working in form 1 Button:
private void button1_Click(object sender, EventArgs e)
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = true;
startInfo.UseShellExecute = false;
startInfo.FileName = "msiexec.exe";
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.Arguments = "/i DoubleAgent.msi /qn";
try
{
// Start the process with the info we specified.
// Call WaitForExit and then the using statement will close.
using (Process exeProcess = Process.Start(startInfo))
{
exeProcess.WaitForExit();
MessageBox.Show("Finish");
}
}
catch
{
// Log error.
}
}
But the same code does not work during the installation process.
This isn't going to work! One MSI setup cannot launch another MSI setup. When it says "another install is in progress" it is referring to your one that is already running. It's not about admin privilege - you cannot install another MSI from an installer custom action, no matter what that developer says.
In general this is what bootstrappers are for, to install prerequisites before installing the main MSI. That's why even VS setups let you generate a setup.exe to install prerequisites (many of which are MSI-based) before installing your MSI.
So you'll need to figure out a bootstrapper (don't know if InstallShield LE has one) that will install that MSI. There used to be a tool called Bootstrap Manifest Generator that you could use to tailor the setup.exe to install custom prerequisiyes like yours. Or you could use the bootstrapper from WiX to install that MSI then your MSI. Or you could just copy that MSI to the system and have your app install it the first time it is used.
Or maybe that agent software is available as merge modules, in which case you just add the merge modules to your MSI build.
Related
At work I have to uninstall the same application several times per day (and reinstall new versions). I'm trying to make a C# program that I can run that will do this all for me. Right now, I'm stuck on the uninstall process.
The code I have runs and attempts to uninstall the application, but Windows gives me an error during this.
Here's what I have right now:
static void Main(string[] args)
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_Product");
const string prodName = "myApp";
Console.WriteLine("searching...");
foreach (ManagementObject wmi in searcher.Get())
{
if (wmi["Name"].ToString() == prodName)
{
Console.WriteLine("found");
string productCode = "/x {" + wmi.Properties["IdentifyingNumber"].Value.ToString() + "}";
Process p = new Process();
p.StartInfo.FileName = "msiexec.exe";
p.StartInfo.Arguments = productCode;
p.Start();
Console.WriteLine("Uninstalled");
break;
}
}
Console.ReadLine();
}
This is the error I get when it tries to do the uninstall:
"This installation package could not be opened. Verify that the package exists and that you can access it, or contact the application vendor to verify that this is a valid Windows Installer package"
Uninstall Reference: This old answer might have what you need: Uninstalling an MSI file from the command line without using msiexec. It shows various ways to uninstall an MSI.
DTF: The DTF (Desktop Tools Foundation) included with the WiX toolset can be used to uninstall. Here is some sample C# code:
Uninstalling program
- run elevated, quick link to sample.
VBScript / COM: Here are some links to VBScript samples and various ways to uninstall (uninstall by product name, uninstall by upgrade code, etc...): WIX (remove all previous versions) - the uninstall by upgrade code (sample code towards bottom) is interesting because it generally works for all versions and incarnations of your installer (upgrade code tends to remain stable across releases).
CMD.EXE: Personally I might just use an install and an uninstall batch file. More of these samples in section 3 here. Just create two different files:
Install: msiexec.exe /i "c:\Setup.msi" /QN /L*V "C:\msi.log" REBOOT=ReallySuppress
Uninstall: msiexec.exe /x "c:\Setup.msi" /QN /L*V "C:\msi.log" REBOOT=ReallySuppress
I am trying to insert msi file using asp.net application. when i run visual studio in administrators mode it is working fine but when i run it in normal mode it is not working.
I had tried following code:
string installerFilePath;
installerFilePath = #"D:\ActivexPractice\test\test\NewFolder1\setup.msi";
System.Diagnostics.Process installerProcess = System.Diagnostics.Process.Start(installerFilePath, "/q");
can any body guide me on this
how to install it without administrators right
You can use msiexec.exe to run installer. Here is sample code.
Process installerProcess = new Process();
ProcessStartInfo processInfo = new ProcessStartInfo();
processInfo.Arguments = #"/i D:\ActivexPractice\test\test\NewFolder1\setup.msi /q";
processInfo.FileName = "msiexec";
installerProcess.StartInfo = processInfo;
installerProcess.Start();
installerProcess.WaitForExit();
If the MSI requires admin rights to install then it will ask for elevation in a UI install. Your /q is failing because a silent install is really silent and will not prompt for elevation. Note that limited users are not allowed to break security rules simply because they are doing an install.
So in that situation your launching process would need to be elevated, either by running as administrator or giving it a requiresAdministrator manifest so it asks for elevation.
When you fire off the install you need to make sure that your elevated state is used to fire off the install. The simplest way to guarantee this is to just call (p/invoke to...) MsiInstallProduct () directly from your code. The issue with Process.Start is that by default ProcessStartInfo.UseShellExecute is true and your elevated state (if you have one) will not be used to start the install. When the install is launched it needs to be a CreateProcess type of execution rather than a ShellExecute type so that your elevated credentials are used.
static void installMSIs(string path)
{
string[] allFiles = Directory.GetFiles(path, "*.msi");
foreach (string file in allFiles)
{
System.Diagnostics.Process installerProcess =
System.Diagnostics.Process.Start(file, "/q");
while (installerProcess.HasExited == false)
{
installerProcess.WaitForExit();
}
}
}
I have a .exe file which checks the system architecture and based on the system architecture it calls the corresponding msi file.
I am trying to run this exe file from C# using the code below
Process process = new Process();
process.StartInfo.FileName = "my.exe";
process.StartInfo.Arguments = "/quiet";
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.StartInfo.WorkingDirectory = "path//to//exe//directory";
Console.WriteLine(process.StartInfo.WorkingDirectory);
process.Start();
process.WaitForExit();
The exe is getting invoked. i can see the application logs and there are no errors in the logs.
But the msi is not getting started or installed.
When I try to run the same exe file manually the msi is installed.
Note: There are other dependency files for this my.exe which are placed in the same directory.
Why am i not able to install the msi from C# program while i am able to do this manually.
I am running the VisualStudios in administrator mode.
You need to execute .exe (and msi) as an administrator.
To ensure that, use:
process.StartInfo.Verb = "runas"
Also, try it removing quiet arguments to see any possible errors.
Is "my.exe" installing your MSI if you call it, isn't it?
I got this resolved after i added Thread.Sleep(). before "process.WaitForExit()"
I am working with Coded UI automation. The issue is to customize test case execution. I cannot use TFS or Lab agent or any other tool. The test components (DLL) are executed through a customized UI developed using C# on a 64bit machine with Win7.
I am able to run test case now through the code below:
string str = "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\IDE\\MSTest.exe";
ProcessStartInfo startInfo = new ProcessStartInfo(str);
startInfo.Arguments = " /testcontainer:TestProject1.dll";
Process.Start(startInfo);
But when I want to install this application to another machine I need to install VS2010. This is what I don't want. I have gone through several doc on the internet, but none of them have a clear picture.If any one can help me with a solution.How to make it work.
I am using Visual Studio Agents 2012 to execute coded UI test without visual studio installed, It works fine for me. you can specify test container,test method, result file name and even test setting file by a bat file and call the MStest.exe in test agents.
Please refer to this
Link
I have completed your requirement.See bellow
public void test()
{
string testcase = "/testcontainer:\"D:\\testcase\\s\\CodedUITest.dll\"";
string Path = "C:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\Common7\\IDE\\mstest.exe";
Process myProcess = new Process();
ProcessStartInfo myProcessStartInfo = new ProcessStartInfo(Path, testcase);
myProcessStartInfo.UseShellExecute = false;
try
{
myProcess.StartInfo = myProcessStartInfo;
myProcess.Start();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
I have a Custom Action that should execute during the Install portion of an .msi setup. I have a previous version that was installed using InstallShield (which was overkill) and wanted to move to the simpler VS Setup Proj because I do not require all the control that an .isproj provides. However, doing a straight install with my new .msi seems to install side by side with the previous version. Here's what I have found out so far:
I have my product ID
I have written code that will uninstall the previous version through creating a process that uses MsiExec.exe (code will follow)
Tried implementing the custom action to uninstall during setup but it seems you can only have one instance of MsiExec.exe running at a time.
Have been to this post (http://stackoverflow.com/questions/197365/vs-setup-project-uninstall-other-component-on-install), which didnt help.
Custom Action code:
//Exe used to uninstall
string fileName = "MsiExec.exe";
//Product ID of versions installed using InstallShield
string productID = "{DC625BCF-5E7B-4FEF-96DD-3CDBA7FC02C1}";
//Use /x for uninstall and use /qn to supress interface
ProcessStartInfo startInfo = new ProcessStartInfo(fileName, string.Format("/x{0}", productID));
startInfo.WindowStyle = ProcessWindowStyle.Normal;
startInfo.UseShellExecute = false;
//Start process
Process uninstallProcess = Process.Start(startInfo);
//Wait until uninstall is complete
uninstallProcess.WaitForExit();
My hope is to eventually deploy my .msi via ClickOnce, so I am hoping for an option that will fit into deployment option. Currently everything is written in .NET 2.0 and VS 2005, but I do have .NET 4.0 and VS 2010 available to me if there is a new option that works.
Any help is appreciated.
I was able to install over the top of the previous install by making the product code of my setup the same as the code of the older version. Didn't dawn on me to try that because when you create a new version of the setup package, VS always prompts you to change your product code.