I am installing cab file of my application using wceload.exe. When my application already exists it gives message "My application is already installed.Reinstall?" How to avoid this message? Cab file installation launches when I use
ProcessStartInfo info = new ProcessStartInfo();
info.FileName = #"\windows\wceload.exe";
info.Arguments = "\\My_Installer.cab";
Process proc = new Process();
proc.StartInfo = info;
proc.Start();
proc.WaitForExit();
When I use
info.Arguments = "\\My_Installer.cab /silent";
or
info.Arguments = "/noaskdest /noui \\My_Installer.cab";
nothing happens. What am I doing wrong?
Here is complete solution, if it will be necessary for somebody:
ProcessStartInfo info = new ProcessStartInfo();
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
Process proc = new Process();
// uninstalls application
doc.LoadXml("<wap-provisioningdoc>" +
"<characteristic type=\"UnInstall\">" +
"<characteristic type=\"MyManufactuer MyApplication\">"+
"<parm name=\"uninstall\" value=\"1\"/>" +
"</characteristic>" +
"</characteristic>" +
"</wap-provisioningdoc>");
Microsoft.WindowsMobile.Configuration.ConfigurationManager.ProcessConfiguration(doc, false);
// installs application
info.FileName = #"\windows\wceload.exe";
info.Arguments = #"\My_Installer.cab";
// start the process
proc.StartInfo = info;
proc.Start();
proc.WaitForExit();
Related
This is my code:
string damnfile = System.IO.Path.GetDirectoryName(choofdlog.FileName);
ProcessStartInfo startInfo = new ProcessStartInfo("% ProgramFiles %\\Windows Defender\\MpCmdRun.exe");
startInfo.WindowStyle = ProcessWindowStyle.Maximized;
startInfo.Arguments = "-Scan -ScanType 3 -File" + damnfile;
Process p = new Process();
p.StartInfo = startInfo;
p.Start();
As you can see, I want to run WinDefender scan for a specific file, but it throws error that the process is not found, but this code works:
ProcessStartInfo startInfo = new ProcessStartInfo("netstat");
startInfo.WindowStyle = ProcessWindowStyle.Maximized;
startInfo.Arguments = "-a";
Process p = new Process();
p.StartInfo = startInfo;
p.Start();
Also I want in the second code to redirect the cmd output to listBox, but thats the second problem, first help me with the defender scan please.
Solveded like now its opening, because I replaced
ProcessStartInfo startInfo = new ProcessStartInfo("% ProgramFiles %\\Windows Defender\\MpCmdRun.exe");
with
ProcessStartInfo startInfo = new ProcessStartInfo(#"C:\Program Files\\Windows Defender\\MpCmdRun.exe");
Now appeared another problem: even I passed some arguments, the windows immediately close.
System.Diagnostics.Process process1;
process1= new System.Diagnostics.Process();
process1.EnableRaisingEvents = false;
string strCmdLine;
strCmdLine = "/k " +textBox3.Text;
System.Diagnostics.Process.Start("CMD.exe",strCmdLine);
This will run a command on cmd ..
Want to save that CMD command text on text file..
Using this for save but not working..
ProcessStartInfo PSI = new ProcessStartInfo();
PSI.FileName = "c:\\WINDOWS\\System32\\cmd.exe";
PSI.RedirectStandardInput = true;
PSI.RedirectStandardOutput = true;
PSI.RedirectStandardError = true;
PSI.UseShellExecute = false;
Process p = Process.Start(PSI);
string output = p.StandardOutput.ReadToEnd();
StreamWriter st = new StreamWriter(#"C:\test.txt");
st.Write(output);
st.Close();
Try this
using System.Diagnostics;
Process.Start("cmd", "/k " + textBox3.Text + #" > C:\test.txt");
Also, read Embedding a Console in a C# Application - CodeProject
Hello I've to Launch the software CFast for a Parametric Analysis. To do this, I want to create a application in C# that runs the core CFast.exe. If I want run the software from cmd.exe and execute it on the file INPUTFILENAME.in I write in prompt:
CFast.exe INPUTFILENAME
In C# I wrote the following code:
Process firstProc = new Process();
firstProc.StartInfo.FileName = #"C:\Users\Alberto\Desktop\Simulazioni Cfast\D\C\N\A3B1\CFAST.exe";
firstProc.StartInfo.Arguments = #"INPUTFILENAME";
firstProc.EnableRaisingEvents = true;
firstProc.Start();
firstProc.WaitForExit();
With this code CFast run but doesn't analyze anything... Seems like don't accept the argument. Hint for this trouble ?
Solved. Mistake in the filename and in the syntax of the command
// setup cmd process
var command = #"CFAST.exe C:\Users\Alberto\Desktop\Simulazioni_Cfast\D\C\N\A3B1\A3B1";
ProcessStartInfo procStartInfo = new ProcessStartInfo("cmd", "/c " + command);
procStartInfo.RedirectStandardOutput = true;
procStartInfo.UseShellExecute = false;
procStartInfo.RedirectStandardError = true;
procStartInfo.CreateNoWindow = true;
// start process
Process proc = new Process();
proc.StartInfo = procStartInfo;
proc.Start();
proc.WaitForExit();
// read process output
string cmdError = proc.StandardError.ReadToEnd();
string cmdOutput = proc.StandardOutput.ReadToEnd();
where A3B1 is the name of the file .IN
When I run the package in Visual Studio the files print. When I deploy it and run it as a SQL Server job the files do not print. Any ideas? The package RUN AS is a domain admin account.
Here is the code.
ProcessStartInfo info = new ProcessStartInfo();
info.Verb = "PrintTo";
info.Arguments = "\"printername\"";
info.FileName = path;
info.CreateNoWindow = true;
info.WindowStyle = ProcessWindowStyle.Hidden;
Process p = new Process();
p.StartInfo = info;
p.Start();
p.WaitForInputIdle();
System.Threading.Thread.Sleep(3000);
if (false == p.HasExited)
p.Kill();
I tried to print a pdf file from my windows service.It didnt work.Later i wrote a console app to print a pdf file.Console app did work!.Afterwords i i called that console app from service to print pdf file it didn'work. Why is that "print" doesnt work with windows service? following are the code snippets i tried
1.Used adobe reader:
PdfReportGeneration.Log logs = new PdfReportGeneration.Log();
logs.writeLog("PrintDocument filepath:-" + filepath);
Process process = new Process();
process.StartInfo.FileName = filepath;
process.StartInfo.UseShellExecute = true;
process.StartInfo.Verb = "printTo";
process.StartInfo.Arguments = "HP LaserJet P1005";
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.Start();
process.WaitForInputIdle();
process.Kill();
2. Used foxit reader/adobe reader both didnt work
string sArgs = " /t \"" + filepath + "\" \"" + "HP LaserJet P1005" + "\"";
System.Diagnostics.ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = #"C:\Program Files\Foxit Software\Foxit Reader\Foxit Reader.exe";
startInfo.Verb = "printTo";
startInfo.Arguments = sArgs;
startInfo.CreateNoWindow = true;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
System.Diagnostics.Process proc = Process.Start(startInfo);
proc.WaitForExit(100000); // Wait a maximum of 10 sec for the process to finish
if (!proc.HasExited)
{
proc.Kill();
proc.Dispose();
// return false;
}*/
Done a lots of google bing yahoo.. no use!!
Service is usually run by different account. I would try to run service as user. Could be a problem that system user doesn't have mapped that printer. Service install class would look like this:
[RunInstaller(true)]
public class ServiceInstall : Installer
{
public ServiceInstall()
{
ServiceInstaller serviceInstaller = new ServiceInstaller();
ServiceProcessInstaller serviceProcessInstaller = new ServiceProcessInstaller();
serviceProcessInstaller.Account = ServiceAccount.User;
serviceProcessInstaller.Username = "User";
serviceProcessInstaller.Password = "Password";
serviceInstaller.DisplayName = "Some Service";
serviceInstaller.StartType = ServiceStartMode.Automatic;
serviceInstaller.ServiceName = "Some Service";
this.Installers.Add(serviceProcessInstaller);
this.Installers.Add(serviceInstaller);
}
}