Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Call .exe program with pass parameters from my Drive C #3459


User avatar
0
kwanp created

Hi

it is possible when i click the left menu and then call .exe program with pass parameters to my Drive C:\

i follow the help from internet

function executeCommands(inputparms)
{
  var oShell = new ActiveXObject("Shell.Application");
  var commandtoRun = "C:\\WINDOWS\\Notepad.exe";
  if (inputparms != "")
  {
    var commandParms = document.Form1.filename.value;
  }
  oShell.ShellExecute(commandtoRun, commandParms, "", "open", "1");
}

it not working

Thank you


4 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    You can use Process.Start, see <a class="postlink" href="https://stackoverflow.com/questions/3268022/process-start-arguments">https://stackoverflow.com/questions/326 ... -arguments</a>.

    Thanks.

  • User Avatar
    0
    kwanp created

    Hi can you please give me the sample how to implement Process.start() i already try put in .ts file but when i click the error show

    ERROR TypeError: Cannot read property 'Process' of undefined
        at PhoneBookComponent.webpackJsonp.2170.PhoneBookComponent.callExe (phonebook.component.ts:40)
        at Object.eval [as handleEvent] (PhoneBookComponent.html:35)
        at handleEvent (core.es5.js:11914)
        at callWithDebugContext (core.es5.js:13206)
        at Object.debugHandleEvent [as handleEvent] (core.es5.js:12794)
        at dispatchEvent (core.es5.js:8814)
        at core.es5.js:9406
        at HTMLButtonElement.<anonymous> (platform-browser.es5.js:2687)
        at ZoneDelegate.webpackJsonp.666.ZoneDelegate.invokeTask (zone.js:398)
        at Object.onInvokeTask (core.es5.js:4140)
        at ZoneDelegate.webpackJsonp.666.ZoneDelegate.invokeTask (zone.js:397)
        at Zone.webpackJsonp.666.Zone.runTask (zone.js:165)
        at HTMLButtonElement.ZoneTask.invoke (zone.js:460)
    

    and this is the code that i try on .ts file

    callExe(): void{
            var p = new System.Diagnostics.Process();
            p.StartInfo.FileName = "notepad.exe";
            p.StartInfo.Arguments = "Test";
            p.StartInfo.RedirectStandardOutput = true;     
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.CreateNoWindow = true;
            p.Start();
            p.StandardOutput.ReadToEnd().Dump();
        }
    

    and this the button that i try to call

    <button (click)="callExe()" class="btn default" type="submit"><i class="icon-magnifier"></i></button>
    

    Thank you

  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    The sample shared by @ismcagdas is for C# (server side). You can not run an exe program in user's local computer (from browser) as I know. ActiveX way may work but I don't think it's supported by all browsers. BTW, this is out of AspNet Zero's scope because it's a general topic. If you can do it in javascript in another application, you can do it within AspNet Zero too.

  • User Avatar
    0
    kwanp created

    Ok it clear to me now

    Thank you