Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to call notepad from windows service

How to call notepad from windows service

Scheduled Pinned Locked Moved C#
helptutorial
3 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    ravindradonkada
    wrote on last edited by
    #1

    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();

    S V 2 Replies Last reply
    0
    • R ravindradonkada

      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();

      S Offline
      S Offline
      sindhutiwari
      wrote on last edited by
      #2

      System.Diagnostics.Process.Start("notepad");

      its me sid

      1 Reply Last reply
      0
      • R ravindradonkada

        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();

        V Offline
        V Offline
        Vasudevan Deepak Kumar
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups