From eef0aacc0f5f7a3e1c600d29ffe257a16da669b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Acun=CC=83a?= Date: Tue, 29 Aug 2017 16:12:41 -0300 Subject: [PATCH] Windows picture retry with snapshot --- lib/agent/providers/webcam/windows/index.js | 27 +++++++++++++++------ 1 file changed, 20 insertions(+), 7 deletions(-) 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