locked
Run cmd commands with an HTML/JS Metro style app

    Question

  • Is there a way to run cmd commands on HTML/JS Metro apps?

     

    like you know by clicking/tapping the "button" it will execute a command

    • Edited by Varemenos Wednesday, September 14, 2011 8:01 PM
    Wednesday, September 14, 2011 8:00 PM

Answers

  • Within the click handler for the button you can make calls to the WinRT API, but I don't think the app sandbox for Metro apps are able to launch arbitrary processes. You can use the launch method to open a url or open a file based on its file association.

    You would probably be better off looking to see if the operations you wish to perform can be handled via the WinRT API.

    Thursday, September 15, 2011 1:16 AM

All replies

  • To wire up a click handler to a button you should add an event listener for the click handler.

    var btn = document.getElementById("idForMyBtn");
    
    btn.addEventListener("click", function(){ // code here });
    

     

    The MSDN documentation for the IE9 addEventListener is applicable:

    http://msdn.microsoft.com/en-us/library/ff975245(v=VS.85).aspx 


    Wednesday, September 14, 2011 9:27 PM
  • The problem is not the eventlistener/handler but how i execute a cmd command with the button
    Wednesday, September 14, 2011 10:20 PM
  • What does the cmd need to do? If you're trying to launch another application you'll need to use Windows.System.Launcher API.

    Wednesday, September 14, 2011 11:30 PM
  • Within the click handler for the button you can make calls to the WinRT API, but I don't think the app sandbox for Metro apps are able to launch arbitrary processes. You can use the launch method to open a url or open a file based on its file association.

    You would probably be better off looking to see if the operations you wish to perform can be handled via the WinRT API.

    Thursday, September 15, 2011 1:16 AM