2

Let me start out by saying I know this is highly not recommended, but for the sake of figuring something out, I'm wanting to launch Notepad via a Webservice...

        Dim p As New Process
        Dim pi As ProcessStartInfo = New ProcessStartInfo
        Dim fullPath As String = "C:\windows\notepad.exe"
        pi.FileName = fullPath
        pi.CreateNoWindow = False
        pi.WindowStyle = ProcessWindowStyle.Maximized
        p.StartInfo = pi
        p.Start()

This code executes without issue and it does in fact launch Notepad as I can see it running in Task Manager, however there is no window for Notepad displayed. How do I go about making the window visible when I launch it?

Filburt
  • 17,626
  • 12
  • 64
  • 115
jay
  • 434
  • 1
  • 5
  • 25
  • 1
    maybe it's running for another user's account? – VladL Feb 27 '14 at 18:56
  • Ooh, didn't even think about that. Let me check and see. – jay Feb 27 '14 at 18:59
  • Ok, so I have confirmed that it is now running the application as the current logged in user however, there is still no window. – jay Feb 27 '14 at 19:13
  • 1
    Looks like it's not very simple http://stackoverflow.com/questions/267838/how-can-a-windows-service-execute-a-gui-application – VladL Feb 27 '14 at 19:22
  • Ok, thanks. Looks like I'm going to need to look at "CreateProcessAsUser". Thanks for the help. – jay Feb 27 '14 at 19:28
  • Please close this question if you have an answer – Sam Makin Apr 03 '14 at 12:55
  • I use Process.Start with no problem. E.G. Process.Start("IExplore", "http://www.somewebsite.com") launches an internet explorer window with the given website as a parameter. not from a webservice though. I assume process.start is just a shorthand way of doing what you have done in the code above. – kenjara Apr 03 '14 at 13:55

1 Answers1

0

Consider the following script this can be used to run the notepad application from the web by calling the function openApplication()

<script language="javascript" type="text/javascript">
    function openApplication()
    {
        var winShell = new ActiveXObject("WScript.Shell");
        var prog = "c:\\WINDOWS\\system32\\notepad.exe";
        winShell.Run('"'+prog+'"',1);
    }
</script>