windowscmdtidesdk

How to kill a windows application using TideSDK?


i am trying to run a command like TASKKILL /F /IM notepad.exe

var process = Ti.Process.createProcess({args: ['TASKKILL /F /IM notepad.exe']});
process.launch();

or

Ti.Process.launch('TASKKILL /F /IM skype.exe');

the debugger doesn't say much, just Error launching 'TASKKILL /F /IM notepad.exe'

documentation

any ideas?


Solution

  • In order to create process I use this syntax (coffeeScript) :

    customProcess = Ti.Process.createProcess([
      arg1
      arg2
      arg3
    ])
    customProcess.launch()
    

    Here is an example of how I use Ti.Process : executing the wkhtmltopdf binary in order to create a pdf from HTML/CSS. So I use the following :

    pdfProcess = Ti.Process.createProcess([
       Ti.API.application.getResourcesPath() + '/wkhtmltopdf/builds/win32/wkhtmltopdf/bin/wkhtmltopdf.exe'
       '--margin-bottom'
       30
       '--margin-top'
       40
       sourcePath
       '--header-html'
       headerPath
       '--footer-html'
       footerPath
       destinationPath
    ])
    pdfProcess.launch()
    

    I haven't tried but maybe the following will work :

    exitProcess = Ti.Process.createProcess([
        'TASKKILL'
        '/F'
        '/IM'
        'notepad.exe'
    ])
    exitProcess.launch()
    

    I think you'll have to split each argument of your process in a item of a list.