Error opening the IExpress Self Extraction Directive file

203 Views Asked by At

So I tried to make a program in C# that connects two .exe files by IExpress command but it throws an error in the title of the thread.

Code that seems to not work:

StreamWriter sw = new StreamWriter(File.OpenWrite(@$"{workdir}\script.sed"));
sw.Write($"[Version] \nClass=IEXPRESS \nSEDVersion=3 \n[Options] \nPackagePurpose=InstallApp \nShowInstallProgramWindow=0 \nHideExtractAnimation=1 \nUseLongFileName=1 \nInsideCompressed=0 \nCAB_FixedSize=0 \nCAB_ResvCodeSigning=0 \nRebootMode=I \nInstallPrompt=%InstallPrompt% \nDisplayLicense=%DisplayLicense% \nFinishMessage=%FinishMessage% \nTargetName=%TargetName% \nFriendlyName=%FriendlyName% \nAppLaunched=%AppLaunched% \nPostInstallCmd=%PostInstallCmd% \nAdminQuietInstCmd=%AdminQuietInstCmd% \nUserQuietInstCmd=%UserQuietInstCmd% \nSourceFiles=SourceFiles \n[Strings] \nInstallPrompt= \nDisplayLicense= \nFinishMessage= \nTargetName={Path.GetFileNameWithoutExtension(file)}+wpkg2.exe \nFriendlyName=All your SEDs are belong to us \nAppLaunched={Path.GetFileName(file)}\nAppLaunched2=wpkg2.exe\nPostInstallCmd=<None> \nAdminQuietInstCmd= \nUserQuietInstCmd= \nFILE0=wpkg2.exe\nFILE1={Path.GetFileName(file)}\n[SourceFiles]\nSourceFiles0={Path.GetDirectoryName(file)}\nSourceFiles1={workdir}\n[SourceFiles0]\n%FILE1%=\n[SourceFiles1]\n%FILE0%=");
sw.Close();

System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = @"C:\Windows\System32\iexpress.exe";
startInfo.Arguments = @$"/N {workdir}\script.sed";
process.StartInfo = startInfo;
//startInfo.UseShellExecute = true;
//startInfo.Verb = "runas";
process.Start();

I tried to execute the command as administrator but it did not work too. (The code that is commented is the code I tried to use to execute command as administrator)

1

There are 1 best solutions below

0
Steven Doggart On

I found that when you run IExpress.exe from the command line using the /N option, it will display that error if the path to the SED file contains spaces. It will display the error whether or not you surround the file path in quotes. I'm only aware of two workarounds:

  1. Make sure you name your SED file, and the folders that contain it, don't contain spaces in their names
  2. Run IExpress without the /N option and specify the SED file path via its wizard UI (in which case spaces are allowed)