Running Latex from C# - c#

When running latex from C# using Process.Start, I'm getting this error: "latex: A required file system path could not be retrieved." It runs fine from the command line, so I'm not sure why it doesn't run from Process.Start. Has anyone run into this issue?
Edit: Also, this is from ASP.NET!
Thanks!

Without seeing more code, my best guess would be to set the WorkingDirectory of your StartInfo class to whatever directory it works from on the command line.
ProcessStartInfo startInfo = new ProcessStartInfo(#"\path\to\latex\latex.exe");
startInfo.WorkingDirectory = #"\path\to\latex";
I've run into this problem before with other EXE's and that seemed to be the fix.

The issue was IIS permissions.

Related

C# - Executing a exe file which further invokes a msi file

I have a .exe file which checks the system architecture and based on the system architecture it calls the corresponding msi file.
I am trying to run this exe file from C# using the code below
Process process = new Process();
process.StartInfo.FileName = "my.exe";
process.StartInfo.Arguments = "/quiet";
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.StartInfo.WorkingDirectory = "path//to//exe//directory";
Console.WriteLine(process.StartInfo.WorkingDirectory);
process.Start();
process.WaitForExit();
The exe is getting invoked. i can see the application logs and there are no errors in the logs.
But the msi is not getting started or installed.
When I try to run the same exe file manually the msi is installed.
Note: There are other dependency files for this my.exe which are placed in the same directory.
Why am i not able to install the msi from C# program while i am able to do this manually.
I am running the VisualStudios in administrator mode.
You need to execute .exe (and msi) as an administrator.
To ensure that, use:
process.StartInfo.Verb = "runas"
Also, try it removing quiet arguments to see any possible errors.
Is "my.exe" installing your MSI if you call it, isn't it?
I got this resolved after i added Thread.Sleep(). before "process.WaitForExit()"

Installing via System.Diagnostics.Process Doesn't Work in 32-Bit/XP?

I have a c# exe that calls System.Diagnostics.Process to run some commands in cmd.exe that installs a couple installers passively.. I've been testing it on my machine (64-bit win8 and it works just fine, but when I run the exe on a 32-bit version of Windows XP, the program simply skips over the process part. There are no errors thrown, it just ignores them. This is my code:
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("CMD.exe", #"/C [command stuff]}");
psi.CreateNoWindow = true;
psi.UseShellExecute = false;
System.Diagnostics.Process diag = System.Diagnostics.Process.Start(psi);
diag.WaitForExit();
diag.Close();
What might be the deal here? Again I get no errors, it just ignores it. It's interesing because I can do all of that up there and just run date as the command and it works fine, but it won't run the msi and exe files needed to install. I can't find any information about it working in 64-bit but not 32. Thanks!
So I found out what my problem was. Before running the .msi to install, I changed directories using the syntax C:/folder/setup.msi. That works fine on my computer, but didn't do anything on the XP one. It turns out it didn't know how to handle the forward slashes. All I had to do was change it to C:\folder\setup.msi and it worked fine. I feel like an idiot, hope this helps someone though lol.

Trying to run slui.exe from within a method using ProcessStartInfo and Process

I'm having an issue with running slui.exe from a method in c#. I'm using the code:
ProcessStartInfo startInfo = new ProcessStartInfo(#"C:\Windows\System32\slui.exe");
Process p = new Process();
p.StartInfo = startInfo;
p.Start();
p.WaitForExit();
but I keep getting a Win32Exception: 'The system cannot find the file specified'.
If I change the ProcessStartInfo to: (#"C:\Windows\System32\cmd.exe") it will launch just fine.
Is there something with running slui.exe in this context that is breaking?
I'm certain that the file is in the directory specified, so I'm stumped as to what may be going wrong here.
Any ideas how to call slui.exe from a c# method?
Slui.exe is only available as a 64-bit program on Windows x64. Your hard-coded path c:\windows\system32 will get re-directed to c:\windows\syswow64 when you run as a 32-bit process. And thus won't find the file.
Project + Properties, Compile tab, change the Platform target setting to "AnyCPU". Repeat for the Release configuration. And use Environment.GetFolderPath() to ensure it still works when Windows isn't installed to c:\windows.

Starting program in C# including all files

I'm having problems running a process from my program.
When I start the process it says "Cannot find Tibia.dat!" ( it thinks the exe file is located in project directory, when it isn't ).
So when I start the process in my program ( from: C:\program\Tibia\Tibia.exe ) it says "Cannot find C:\user\marcus\my documents\visual studio 2009\blablalba\Tibia.dat".
Here's the code I'm using:
Process.Start(addressToFirstTibia + "\\Tibia.exe");
Grateful for help !!
You need to set the working directory. Tibia.exe probably expects it to be the same as the executable's directory, so try:
Process.Start(new ProcessStartInfo {
FileName = Path.Combine(addressToFirstTibia, "Tibia.exe"),
WorkingDirectory = addressToFirstTibia
});
Is Tibia.exe looking for Tibia.dat internally? It may be detecting somehow that the "current working directory" is the project directory, not its own executable directory.
There's a property called WorkingDirectory on ProcessStartInfo that may solve this issue for you. Info can be found here.

The filename, directory name, or volume label syntax is incorrect, c#

i've written a console application deploy.exe which runs a batch script.
Process p1 = new Process();
p1.StartInfo.FileName = AppDomain.CurrentDomain.BaseDirectory + "installer.bat";
p1.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
p1.Start();
p1.WaitForExit();
p1.Close();
the installer.bat conatins the following command.
\shared1\lists\list1.cmd
If i run the executable byitself it runs successfully.
However i needed it to run in a windows installer project. So i made a setup and deployment project and added the deploy.exe successfully as custom action upon install.
It runs fine but when it starts to execute the command i get this error
"The filename, directory name, or volume label syntax is incorrect".
any help?
Try printing out what the value of AppDomain.CurrentDomain.BaseDirectory is. It may not be where installer.bat is when you are installing it.
Also, you tried adding the bat file to a custom action (if that is even possible)?
And, would it possible to move what is in the bat to the exe?
Is it a problem in your batch file?
Check this:
\\shared1\\lists\\list1.cmd
should probably be
\\shared1\lists\list1.cmd
Note the extra \ chars in your original command. That would cause the batch file to give that error.
the error seems to be inside the script which was being executed. It contained environment variables %kind%, which were not acceptable by the installer for some reason. So it was working properly outside the installer and not properly when the installer was calling it.

Categories