C# 在C中安装EXE并指定目录#

C# 在C中安装EXE并指定目录#,c#,startprocessinfo,C#,Startprocessinfo,如何在C#中指定安装特定程序的位置?我尝试使用.WorkingDirectory,但不起作用。我想在桌面的记事本文件夹中安装记事本++安装程序,我该怎么做 static void LaunchInstaller() { ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = @"C:\Users\UserOne\Downloads\npp.6.1.5.Ins

如何在C#中指定安装特定程序的位置?我尝试使用.WorkingDirectory,但不起作用。我想在桌面的记事本文件夹中安装记事本++安装程序,我该怎么做

    static void LaunchInstaller()
    {
        ProcessStartInfo startInfo = new ProcessStartInfo();
        startInfo.FileName = @"C:\Users\UserOne\Downloads\npp.6.1.5.Installer.exe";
        startInfo.WorkingDirectory = @"C:\Users\UserOne\Desktop\NotepadFolder";
        //The line above doesn't work. Notepad++ still installs to its current directory, in ProgramFiles
        startInfo.Arguments = "/S";
        Process.Start(startInfo);
    }
我在上看到了下面的代码。他们没有指定这两个字符串及其参数的用法,所以我现在很困惑:

static void LaunchCommandLineApp()
{
const string ex1 = "C:\\";
const string ex2 = "C:\\Dir";

ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.FileName = "dcm2jpg.exe";
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.Arguments = "-f j -o \"" + ex1 + "\" -z 1.0 -s y " + ex2;

try
{
    Process exeProcess = Process.Start(startInfo)
    {
    exeProcess.WaitForExit();
    }
}
catch{}
}

这与编程无关,我投票决定结束。。。同时

它是使用Nullsoft安装系统v2.46编写的


看看。

这与编程无关,我投票决定结束。。。同时

它是使用Nullsoft安装系统v2.46编写的


看看。

呜呜!谢谢你的链接,我的代码很有效!您只需在参数中添加/D=您的安装目录。。以下是我的更新代码:

    static void LaunchInstaller()
    {
        const string installdir = @"C:\Users\UserOne\Desktop\NotepadFolder";

        ProcessStartInfo startInfo = new ProcessStartInfo();
        startInfo.FileName = @"C:\Users\UserOne\Downloads\npp.6.1.5.Installer.exe";
        startInfo.Arguments = "/S /D=" + installdir; //My new code
        Process.Start(startInfo);
    }

呜呼!谢谢你的链接,我的代码很有效!您只需在参数中添加/D=您的安装目录。。以下是我的更新代码:

    static void LaunchInstaller()
    {
        const string installdir = @"C:\Users\UserOne\Desktop\NotepadFolder";

        ProcessStartInfo startInfo = new ProcessStartInfo();
        startInfo.FileName = @"C:\Users\UserOne\Downloads\npp.6.1.5.Installer.exe";
        startInfo.Arguments = "/S /D=" + installdir; //My new code
        Process.Start(startInfo);
    }

什么?我用C#来创建一个控制台应用程序来调用安装程序,我认为这是在编程……是的,但这不是你真正的问题。您的问题是“我在哪里可以找到更多关于npp安装程序选项的信息”。您似乎没有在编程方面遇到困难。谢谢您的链接。这真的很有帮助。我将删除帖子中的参数部分。什么?我用C#来创建一个控制台应用程序来调用安装程序,我认为这是在编程……是的,但这不是你真正的问题。您的问题是“我在哪里可以找到更多关于npp安装程序选项的信息”。您似乎没有在编程方面遇到困难。谢谢您的链接。这真的很有帮助。我将删除我文章中的参数部分。您可能也会发现这个页面很有趣:我还尝试使用dotnetperls提供的代码,认为ex1是安装程序的位置,ex2是要安装的目标。它仍然不起作用。我将切换到我的原始代码。有人能告诉我我的代码有什么问题吗?你可能也会发现这个页面很有趣:我还尝试使用dotnetperls提供的代码,认为ex1是安装程序的位置,ex2是要安装的目标。它仍然不起作用。我将切换到我的原始代码。有人能告诉我我的代码有什么问题吗?