How to call notepad from windows service
-
Hi , This is ravindra,currently working on Windows Service. I implemented the following two methods to call notepad.exe from windows service,but its not working.So,please anybody help to complete my task. Method1: ======= STARTUPINFO si = new STARTUPINFO(); PROCESS_INFORMATION pi = new PROCESS_INFORMATION(); CreateProcess("C:\\WINDOWS\\SYSTEM32\\notepad.exe", null, IntPtr.Zero, IntPtr.Zero, false, 0, IntPtr.Zero, null, ref si, out pi); EventLog.WriteEntry("After notepad"); } [DllImport("kernel32.dll")] static extern bool CreateProcess(string lpApplicationName, string lpCommandLine, IntPtr lpProcessAttributes, IntPtr lpThreadAttributes, bool bInheritHandles, uint dwCreationFlags, IntPtr lpEnvironment, string lpCurrentDirectory, ref STARTUPINFO lpStartupInfo, out PROCESS_INFORMATION lpProcessInformation); } } Method2: ======== EventLog.WriteEntry("In the notepad"); ProcessStartInfo psi = new ProcessStartInfo(); psi.FileName = "notepad.exe"; psi.UseShellExecute = false; psi.Domain = "sys43."; psi.UserName = "Acer OEM User"; SecureString secure = new SecureString(); string password = "nopassword"; foreach (char c in password) { secure.AppendChar(c); } psi.Password = secure; Process process = new Process(); process.StartInfo = psi; process.Start();
-
Hi , This is ravindra,currently working on Windows Service. I implemented the following two methods to call notepad.exe from windows service,but its not working.So,please anybody help to complete my task. Method1: ======= STARTUPINFO si = new STARTUPINFO(); PROCESS_INFORMATION pi = new PROCESS_INFORMATION(); CreateProcess("C:\\WINDOWS\\SYSTEM32\\notepad.exe", null, IntPtr.Zero, IntPtr.Zero, false, 0, IntPtr.Zero, null, ref si, out pi); EventLog.WriteEntry("After notepad"); } [DllImport("kernel32.dll")] static extern bool CreateProcess(string lpApplicationName, string lpCommandLine, IntPtr lpProcessAttributes, IntPtr lpThreadAttributes, bool bInheritHandles, uint dwCreationFlags, IntPtr lpEnvironment, string lpCurrentDirectory, ref STARTUPINFO lpStartupInfo, out PROCESS_INFORMATION lpProcessInformation); } } Method2: ======== EventLog.WriteEntry("In the notepad"); ProcessStartInfo psi = new ProcessStartInfo(); psi.FileName = "notepad.exe"; psi.UseShellExecute = false; psi.Domain = "sys43."; psi.UserName = "Acer OEM User"; SecureString secure = new SecureString(); string password = "nopassword"; foreach (char c in password) { secure.AppendChar(c); } psi.Password = secure; Process process = new Process(); process.StartInfo = psi; process.Start();
System.Diagnostics.Process.Start("notepad");
its me sid
-
Hi , This is ravindra,currently working on Windows Service. I implemented the following two methods to call notepad.exe from windows service,but its not working.So,please anybody help to complete my task. Method1: ======= STARTUPINFO si = new STARTUPINFO(); PROCESS_INFORMATION pi = new PROCESS_INFORMATION(); CreateProcess("C:\\WINDOWS\\SYSTEM32\\notepad.exe", null, IntPtr.Zero, IntPtr.Zero, false, 0, IntPtr.Zero, null, ref si, out pi); EventLog.WriteEntry("After notepad"); } [DllImport("kernel32.dll")] static extern bool CreateProcess(string lpApplicationName, string lpCommandLine, IntPtr lpProcessAttributes, IntPtr lpThreadAttributes, bool bInheritHandles, uint dwCreationFlags, IntPtr lpEnvironment, string lpCurrentDirectory, ref STARTUPINFO lpStartupInfo, out PROCESS_INFORMATION lpProcessInformation); } } Method2: ======== EventLog.WriteEntry("In the notepad"); ProcessStartInfo psi = new ProcessStartInfo(); psi.FileName = "notepad.exe"; psi.UseShellExecute = false; psi.Domain = "sys43."; psi.UserName = "Acer OEM User"; SecureString secure = new SecureString(); string password = "nopassword"; foreach (char c in password) { secure.AppendChar(c); } psi.Password = secure; Process process = new Process(); process.StartInfo = psi; process.Start();
You already have a running query over here: http://www.codeproject.com/script/Forums/View.aspx?fid=1649&msg=2382014[^] Please refrain from posting the same query multiple times.
Vasudevan Deepak Kumar Personal Homepage
Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson