Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
342 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 Reply

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);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...