diff --git a/lib/agent/providers/webcam/windows/index.js b/lib/agent/providers/webcam/windows/index.js index c66cf6ecb..0a8b3fb0c 100644 --- a/lib/agent/providers/webcam/windows/index.js +++ b/lib/agent/providers/webcam/windows/index.js @@ -1,13 +1,26 @@ -var exec = require('child_process').exec, +var fs = require('fs'), + exec = require('child_process').exec, join = require('path').join; exports.get_picture = function(file, callback){ - var cmd = '"' + join(__dirname, '/prey-webcam.exe') + '"'; - cmd += ' -invalid youcam,cyberlink,google -frame 10 -outfile ' + file; + var exes = ['/prey-wecam.exe', '/snapshot.exe'], + opts = [' -invalid youcam,cyberlink,google -frame 10 -outfile ', ' /T ']; - exec(cmd, function(err) { - callback(err, 'image/jpeg'); // if err exists, content_type will not matter - }) + var picture_command = function(index) { + return '"' + join(__dirname, exes[index]) + '"' + opts[index] + file; + } -} + var take_picture = function(method) { + exec(picture_command(method), function(err) { + if (!fs.existsSync(file) && method == 0) { + file = file.replace(/.jpg/g, ''); + take_picture(1); + } else + callback(err, 'image/jpeg'); // if err exists, content_type will not matter + }) + } + + take_picture(0); + +} \ No newline at end of file