C# Commandline , run two command

73 views Asked by At

I tried to create Installer for my application. I want befor install new version,so uninstall old version. Iusing Command line to solve.

This is my Command :

start /b msiexec.exe /x{79735753-F9D4-49AD-B29E-55C578390D25} /passive &cmd /k "e:\22-08-2016\setup.exe"

But Uninstall command not yet finish, then install start. I want Uninstall command complete then deloy install command.

How to do that.

PS: I create installer by Installshiedl 2015, if have way to create uninstall before install, please show for me, thanks.

2

There are 2 answers

0
Mohit S On

You can use Process.WaitForExit Method:

public void run2ndCmd()
{
    String command = @"e:\22-08-2016\setup.exe";
    ProcessStartInfo cmdsi = new ProcessStartInfo("cmd.exe");
    cmdsi.Arguments = command;
    Process cmd = Process.Start(cmdsi);
    cmd.WaitForExit();    
}
public void run1stCmd()
{
    String command = @"/b msiexec.exe /x{79735753-F9D4-49AD-B29E-55C578390D25} /passive &cmd /k";
    ProcessStartInfo cmdsi = new ProcessStartInfo("cmd.exe");
    cmdsi.Arguments = command;
    Process cmd = Process.Start(cmdsi);
    cmd.WaitForExit();    
}
public void runCmd()
{
    run1stCmd();
    //This will execute only when 1st command is finished
    run2ndCmd()
}
0
PhilDW On

Unless you have a good reason for doing it that way, why not just do the more normal major upgrade. This will install the new version as well as uninstall that older version. I'm not sure which version of InstallShield you have, but this is the documentation:

http://helpnet.installshield.com/installshield22helplib/helplibrary/UpgradeMsiMajorAdvanced.htm