Node.js NW JS Node JS在Windows XP上执行命令

Node.js NW JS Node JS在Windows XP上执行命令,node.js,cmd,windows-xp,node-webkit,Node.js,Cmd,Windows Xp,Node Webkit,我正在用NWJS开发一个桌面应用程序,我正在尝试执行一个命令来获取文件的属性,但它在任何使用Windows XP的计算机上都不起作用,下面是代码: 在Windows 7和8上,它工作正常,我得到了属性,但在Win XP上没有任何功能。。。没有错误,没有警报,什么都不做。 但是,如果在cmd终端中复制/粘贴代码,它就会工作 home.executeWinCmd = function () { console.log('executing command'); var termi

我正在用NWJS开发一个桌面应用程序,我正在尝试执行一个命令来获取文件的属性,但它在任何使用Windows XP的计算机上都不起作用,下面是代码:

在Windows 7和8上,它工作正常,我得到了属性,但在Win XP上没有任何功能。。。没有错误,没有警报,什么都不做。 但是,如果在cmd终端中复制/粘贴代码,它就会工作

home.executeWinCmd = function () {

    console.log('executing command');

    var terminal = require('child_process').spawn('cmd');

    terminal.stdout.on('data', function (data) {
        console.log('stdout: ' + data);
    });

    terminal.stderr.on('data', function (data) {
        console.log('stderr: ' + data);
    });

    terminal.on('exit', function (code) {
        console.log('child process exited with code ' + code);
    });

    setTimeout(function() {
        console.log('Sending stdin to terminal');

        var command = '';

        if($scope.config != undefined) {
            if($scope.config.clientPath == undefined) {
                command = 'wmic datafile where name="' + $scope.config.clientPath + '" get version\n';
            } else {
                command = 'wmic datafile where name="C:\\\\Clients\\\\StaClient.exe" get version\n';
            }
        } else {
            command = 'wmic datafile where name="C:\\\\Clients\\\\StaClient.exe" get version\n';
        }

        console.log('command ' + command);
        terminal.stdin.write(command);

        terminal.stdin.end();
    }, 1000);

}
编辑1 这是工作了。。。出于某种原因

现在这段代码不起作用了,本质上是一样的,当我使用exec时,它什么都不做,没有错误,没有stderr,没有stdout,什么都不做。这真令人不安

NodeModules.exec('wmic datafile where name="' + $scope.config.clientPath + '" get version', function (err, stdout, stderr) {
    if (err) {
        console.log(err);
        Logger.log('ERRR', 'Error executing command: ' + err);
        return;
    }

    if (stderr.length > 0) {
        console.log(stderr);
        Logger.log('ERRR', 'No Client Present return from stderr: ' + stderr);
        $scope.timeout = $timeout($scope.timeoutFn, 3000);
        return;
    }

    $scope.config.currentVersion = (stdout.substring('Version '.length, stdout.length)).trim();
    $scope.config.phase = Enums.Phase.CHECK_RECENT;
    Logger.log('REPR', 'Current Version ' + $scope.config.currentVersion);

});

这是“以管理员身份运行”问题吗?已尝试。还是没有work@GabrielMatusevich你最终找到解决办法了吗?今天在Windows XP SP3上运行wmic OS get Caption时,我遇到了类似的问题。我最终使用了Electron(Atom Shell)。。。但我认为问题与许可证有关谢谢你@GabrielMatusevich这是一个“以管理员身份运行”的问题?已经尝试过了。还是没有work@GabrielMatusevich你最终找到解决办法了吗?今天在Windows XP SP3上运行wmic OS get Caption时,我遇到了类似的问题。我最终使用了Electron(Atom Shell)。。。但我认为问题与许可证有关谢谢你@GabrielMatusevich