Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
344 views
in Technique[技术] by (71.8m points)

wpf - Installing a program with setup.exe including multiple msi-files using C# process from a subfolder

In my C# WPF application I want to install an other program. The other program consists of a setup.exe, multiple msi files and a vcredist.exe. I need to start the setup.exe because it hands over some parameters and information to the msi files and uses an update functionality for the existing version of the program. So I can't start the msi files directly.

programPath = programPath + @"setup.exe";
Process programsetup = Process.Start(programPath);
programsetup.WaitForExit();

Files are stored in root directory of my C# app. My problem is that I can't move the files to an subfolder because the msi files are always searched in the root directory and not in the subfolder.

now:

  • ..myAppsetup.exe
  • ..myAppclient.msi
  • ..myApphost.msi
  • ..myAppmanager.msi
  • ..myAppvcredist.exe

My question: How can I move setup.exe and msi files in a subfolder and start it from there?

What I want:

  • ..myAppoolkitsetup.exe
  • ..myAppoolkitclient.msi
  • ..myAppoolkithost.msi
  • ..myAppoolkitmanager.msi
  • ..myAppoolkitvcredist.exe

Error I get during setup when I do it this way: ..myAppclient.msi not found.

question from:https://stackoverflow.com/questions/65882412/installing-a-program-with-setup-exe-including-multiple-msi-files-using-c-sharp-p

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This code will directly launch setup.exe.

Properties -> right click Open to Resources.resx -> Top Left Add Existing File -> select the file.

byte[] resourceFile = Properties.Resources.setup;
        string destination = Path.Combine(Path.GetTempPath(), "setup.exe");
        System.IO.File.WriteAllBytes(destination, resourceFile);
        Process.Start(destination);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...