Use c# to install a program in silent mode by passing parameters

Asked

Viewed 345 times

1

I am trying to create a program that installs several programs silently

some programs that use simple parameters type " /Q" I got and worked

but it has a program that the parameter is big and they are not able to solve

i cannot set a fixed path, as I want my program to work in any directory or folder

the command is this: vcredist_x86.exe /q:a /c:"VCREDI~1.EXE /q:a /c:""msiexec /i vcredist.msi /Qn"" "

via cmd installs perfectly, I’m just not able to do it via c#

I’ve tried several ways but unsuccessfully, an example of a way that I didn’t work:

ProcessStartInfo startInfo = new ProcessStartInfo()
{
    string pathApp = "Visual C++\2005\vcredist_x86.exe";
    FileName = Path.Combine(Environment.CurrentDirectory, pathApp),
    Arguments = " /q:a /c:\"VCREDI~1.EXE / q:a / c:\"\"msiexec / i vcredist.msi / qn\"\" \"",
    WorkingDirectory = Environment.CurrentDirectory,
    WindowStyle = ProcessWindowStyle.Hidden,
    UseShellExecute = true
};

using (Process exeProcess = Process.Start(startInfo))
{
    exeProcess.EnableRaisingEvents = true;
    exeProcess.WaitForExit(60000);
}

error that tells that the file has not been located or it starts to install showing on the screen without being silent mode, as if it had ignored the parameter

OBS: I tried several variations of this code, passing the full path of the program, I tried to create a bat and run the bat but I did not give

what I’m doing wrong?

1 answer

1

Solved

discovered the problem, the visual studio was trolling me, every time I glued the txt it gave space alone so the argument was incorrect

Then I got all the extra space he put in and it worked

example: I copied this " /c:" and it looked like this: "/ c:"

Browser other questions tagged

You are not signed in. Login or sign up in order to post.