locked
Running azure batch interactive mode - take desktop screenshot RRS feed

  • Question

  • I have a task which takes in a bunch of urls, opens a browser for the url and take the desktop screenshot using the handle from GetDesktopWindow in user32.dll. The reason i need to use getdesktopwindow is because i need to take the screenshot with address bar showing the url, if i just need the content i can use some open source drivers which works fine in azure batch. But when i run the task with code to capture the desktop it doesn't work, just get a blank white screenshot. Here is what I'm doing.

    1. Initialize browser instance from selenium web driver.

    2. Navigate to a url using the above browser instance.

    3. Bring the browser to foreground.

    4. Capture desktop screenshot by getting the desktop handle using GetDesktopWindow function and then capturing the screenshot.

    This code works fine when i run locally on my desktop/laptop but doesn't work when i run in batch. Is this even possible to do this in azure batch? 

    If so I'm guessing i need to run in some special interactive mode which allows interaction with desktop? Currently I'm running in default mode using batch service account. Any inputs?


    • Edited by Kiran Bhaga Wednesday, October 18, 2017 5:06 PM
    Wednesday, October 18, 2017 5:05 PM

Answers

  • Hi Kiran,

    Batch doesn't directly support running processes in interactive mode. If you need to run a process in interactive mode, you'll need to do it yourself (from the command line).

    Generally the easiest thing to do if you need to run in interactive mode is use the sysinternals tool psexec, which allows you to run processes under different contexts. You can download the tool here.

    I believe you will want to pass -i 1 to psexec, so your commandline would look like: "cmd /c psexec -i 1 -h -accepteula -w %AZ_BATCH_TASK_WORKING_DIR% <your command line here>"

    Hope this helps some.

    -Matt

    Wednesday, October 18, 2017 5:39 PM

All replies

  • Hi Kiran,

    Batch doesn't directly support running processes in interactive mode. If you need to run a process in interactive mode, you'll need to do it yourself (from the command line).

    Generally the easiest thing to do if you need to run in interactive mode is use the sysinternals tool psexec, which allows you to run processes under different contexts. You can download the tool here.

    I believe you will want to pass -i 1 to psexec, so your commandline would look like: "cmd /c psexec -i 1 -h -accepteula -w %AZ_BATCH_TASK_WORKING_DIR% <your command line here>"

    Hope this helps some.

    -Matt

    Wednesday, October 18, 2017 5:39 PM
  • Thanks Matt !! I'll give it a try to see if it will work.

    Wednesday, October 18, 2017 5:47 PM