Kaseya Community

Screenshot feature

  • While the new screenshot feature is nice, it only captures the primary monitor. 

    It would be *really* useful to capture all existing monitors in the screenshot.  Many of our clients use 2+ monitors.  If an error message or some other type of information we need is not on their primary monitor, the screenshot function doesn't help us at all.

    Please look at NirCMD for a good example on proper screenshots

    Here's a script I wrote a while back that uses NirCMD in order to grab screenshots of ALL monitors in a single jpg file.  You'll need to get nircmdc.exe and I've included my .bat file along with the K2 script below.

    <?xml version="1.0" encoding="utf-8"?>
    <ScriptExport xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.kaseya.com/vsa/2008/12/Scripting">
      <Procedure name="Take screenshot and store in Audit / Documents / Screenshots" treePres="3" id="177411862">
        <Body description="Takes a screen shot of the user's PC  and saves the resulting JPEG in Audit / Documents / Screenshots&#xD;&#xA;&#xD;&#xA;Dan Muntz 11/5/2010&#xD;&#xA;">
          <If description="">
            <Condition name="UserIsLoggedIn">
              <Parameter xsi:type="StringParameter" name="UserName" value="" />
            </Condition>
            <Then>
              <Statement description="Write the selected directory, subdirectories and files to the machine at the path specified." name="WriteDirectory" continueOnFail="false">
                <Parameter xsi:type="StringParameter" name="Path" value="#vAgentConfiguration.agentTempDir#\NirCMD" />
                <Parameter xsi:type="StringParameter" name="SourceDirectory" value="VSASharedFiles\NirCMD\" />
              </Statement>
              <Statement description="Execute the given command as if it were typed in at a command prompt." name="ExecuteShellCommand" continueOnFail="false">
                <Parameter xsi:type="StringParameter" name="Command" value="#vAgentConfiguration.agentTempDir#\NirCMD\screenshot.bat &quot;#vAgentConfiguration.agentTempDir#\NirCMD\&quot;" />
                <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="User" />
                <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="False" />
              </Statement>
              <Statement description="Create a named procedure variable and assign a value retrieved from the managed machine by the agent." name="GetVariable" continueOnFail="false">
                <Parameter xsi:type="EnumParameter" name="VariableType" value="FileContent" />
                <Parameter xsi:type="StringParameter" name="SourceContent" value="#vAgentConfiguration.agentTempDir#\NirCMD\jpgname.txt" />
                <Parameter xsi:type="StringParameter" name="VariableName" value="jpegname" />
              </Statement>
              <Statement description="Get the specified file - full path to file required." name="GetFile" continueOnFail="false">
                <Parameter xsi:type="StringParameter" name="RemoteFileName" value="#vAgentConfiguration.agentTempDir#\NirCMD\#jpegname#" />
                <Parameter xsi:type="StringParameter" name="KServerFileName" value="..\Docs\Screenshots\#jpegname#" />
                <Parameter xsi:type="EnumParameter" name="Action" value="OverwriteNoAlert" />
              </Statement>
              <Statement description="Execute the given command as if it were typed in at a command prompt." name="ExecuteShellCommand" continueOnFail="false">
                <Parameter xsi:type="StringParameter" name="Command" value="rmdir /S /Q #vAgentConfiguration.agentTempDir#\NirCMD" />
                <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="System" />
                <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="False" />
              </Statement>
              <Statement description="Write an Entry into the Procedure Log" name="WriteScriptLogEntry" continueOnFail="false">
                <Parameter xsi:type="StringParameter" name="Comment" value="Screenshot image #jpegname# stored in Audit / Documents" />
              </Statement>
            </Then>
          </If>
        </Body>
      </Procedure>
    </ScriptExport>

    Screenshot.bat:

    @echo off
    @rem Dan Muntz - 11/05/2010
    cd %1

    for /f "tokens=1,2 delims=:" %%A in ('echo %time%') do set curtime=%%A%%B
    for /f "tokens=1,2,3 delims= " %%A in ('echo %date%') do set curdate=%%B
    for /f "tokens=1,2,3 delims=/" %%A in ('echo %curdate%') do set curdate=%%A-%%B-%%C

    echo %curdate%_%curtime%.jpg > jpgname.txt

    rem nircmdc.exe savescreenshotfull %curdate%_%curtime%.jpg

    rem copy what's in clipboard to file
    nircmdc.exe clipboard saveclp tmp.clp

    rem press printsrn key
    nircmdc.exe sendkey 0x2C press

    @ping -n 10 127.0.0.1 1> nul

    rem save image in clipboard to file
    nircmdc.exe clipboard saveimage %curdate%_%curtime%.jpg

    rem revert clipboard to orig state
    nircmdc.exe clipboard loadclp tmp.clp
    del tmp.clp

  • Hi Dan,

    Awesome procedure.  With the new "Quick View" you can add this to your list of preferred procedures and run it as quickly as with the current Screen Shot button.

    - Max

  • Excellent procedure!! Thankabunch!

    Is there by any change a methode to send the last file by email?

  • I had an interesting demo request for the ability to take screenshots across multiple monitors and found this script invaluable but I did rewrite it to auto-deploy the components on script initiation as per the below.  I haven't included the Batchfile (its the same as Dan's above) but the script will expect it to be available in the Managed Files-Shared directory.

    Copy and paste the Xml for import into the Kaseya Agent Procedure directory.

    <?xml version="1.0" encoding="utf-8"?>

    <ScriptExport xmlns:xsi="www.w3.org/.../XMLSchema-instance" xmlns:xsd="www.w3.org/.../XMLSchema" xmlns="www.kaseya.com/.../Scripting">

     <Procedure name="Multi Monitor Screenshot " treePres="3" id="1295063158" folderId="980711683435696" treeFullPath="Proserv">

       <Body description="Takes a screen shot of the user's PC  and saves the resulting JPEG in Audit / Documents / Screenshots&#xA;&#xA;Updated Dan Muntz 11/5/2010&#xA;&#xA;Updated Craig Allen 19/5/2015 to include Application deployment.  No warrantly implied or given.&#xA;&#xA;&#xA;">

         <Statement description="Uopdated NIRCMD script with application download and extract" name="GetVariable" continueOnFail="false" osType="NT4|2000|XP|2003|Vista|2008">

           <Parameter xsi:type="EnumParameter" name="VariableType" value="AgentTempDirectory" />

           <Parameter xsi:type="StringParameter" name="SourceContent" value="" />

           <Parameter xsi:type="StringParameter" name="VariableName" value="kworking" />

         </Statement>

         <Statement name="GetVariable" continueOnFail="false" osType="NT4|2000|XP|2003|Vista|2008">

           <Parameter xsi:type="EnumParameter" name="VariableType" value="MachineGroupID" />

           <Parameter xsi:type="StringParameter" name="SourceContent" value="" />

           <Parameter xsi:type="StringParameter" name="VariableName" value="machinename" />

         </Statement>

         <If description="Deploy pre requisite software.">

           <Condition name="TestFile">

             <Parameter xsi:type="StringParameter" name="Path" value="#kworking#\nircmd.exe" />

             <Parameter xsi:type="EnumParameter" name="Condition" value="NotExists" />

             <Parameter xsi:type="StringParameter" name="Value" value="" />

           </Condition>

         </If>

         <Statement name="GetURL" continueOnFail="false" osType="NT4|2000|XP|2003|Vista|2008">

           <Parameter xsi:type="StringParameter" name="URL" value="nirsoft.net/.../nircmd-x64.zip" />

           <Parameter xsi:type="StringParameter" name="ResponseFileName" value="#kworking#\nircmd-x64.zip" />

           <Parameter xsi:type="BooleanParameter" name="WaitComplete" value="True" />

         </Statement>

         <Statement name="PauseScript" continueOnFail="false" osType="NT4|2000|XP|2003|Vista|2008">

           <Parameter xsi:type="IntegerParameter" name="Seconds" value="30" />

         </Statement>

         <Statement name="Unzip file" continueOnFail="false" osType="Windows">

           <Parameter xsi:type="StringParameter" name="Parameter1" value="#kworking#\nircmd-x64.zip" />

           <Parameter xsi:type="StringParameter" name="Parameter2" value="#kworking#\NIRCMD" />

           <Parameter xsi:type="StringParameter" name="Parameter3" value="True" />

         </Statement>

         <Statement name="PauseScript" continueOnFail="false" osType="NT4|2000|XP|2003|Vista|2008">

           <Parameter xsi:type="IntegerParameter" name="Seconds" value="30" />

         </Statement>

         <Statement name="WriteScriptLogEntry" continueOnFail="false" osType="NT4|2000|XP|2003|Vista|2008">

           <Parameter xsi:type="StringParameter" name="Comment" value="NIRCMD zip successfully downloaded and unpacked on #machinename#" />

         </Statement>

         <If description="">

           <Condition name="TestFile">

             <Parameter xsi:type="StringParameter" name="Path" value="#kworking#\NIRCMD\Screenshot.bat" />

             <Parameter xsi:type="EnumParameter" name="Condition" value="NotExists" />

             <Parameter xsi:type="StringParameter" name="Value" value="" />

           </Condition>

         </If>

         <Statement name="WriteFile" continueOnFail="false" osType="NT4|2000|XP|2003|Vista|2008">

           <Parameter xsi:type="StringParameter" name="Path" value="#kworking#\NIRCMD\Screenshot.bat" />

           <Parameter xsi:type="StringParameter" name="ManagedFile" value="VSASharedFiles\Screenshot.bat" />

           <Parameter xsi:type="BooleanParameter" name="DeleteAfter" value="False" />

         </Statement>

         <Statement name="PauseScript" continueOnFail="false" osType="NT4|2000|XP|2003|Vista|2008">

           <Parameter xsi:type="IntegerParameter" name="Seconds" value="30" />

         </Statement>

         <Statement name="WriteScriptLogEntry" continueOnFail="false" osType="NT4|2000|XP|2003|Vista|2008">

           <Parameter xsi:type="StringParameter" name="Comment" value="Screenshot.bat successfully sent to #machinename#" />

         </Statement>

         <If description="Run screenshot - currently set to overwrite.">

           <Condition name="UserIsLoggedIn">

             <Parameter xsi:type="StringParameter" name="UserName" value="" />

           </Condition>

           <Then>

             <Statement name="ExecuteShellCommand" continueOnFail="false" osType="NT4|2000|XP|2003|Vista|2008">

               <Parameter xsi:type="StringParameter" name="Command" value="#kworking#\NirCMD\screenshot.bat "#kworking#\NirCMD\"" />

               <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="User" />

               <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="False" />

             </Statement>

             <Statement name="GetVariable" continueOnFail="false">

               <Parameter xsi:type="EnumParameter" name="VariableType" value="FileContent" />

               <Parameter xsi:type="StringParameter" name="SourceContent" value="#kworking#\NirCMD\jpgname.txt" />

               <Parameter xsi:type="StringParameter" name="VariableName" value="jpegname" />

             </Statement>

             <Statement name="GetFile" continueOnFail="false" osType="NT4|2000|XP|2003|Vista|2008">

               <Parameter xsi:type="StringParameter" name="RemoteFileName" value="#kworking#\NirCMD\#jpegname#" />

               <Parameter xsi:type="StringParameter" name="KServerFileName" value="..\Docs\Screenshots\#jpegname#" />

               <Parameter xsi:type="EnumParameter" name="Action" value="OverwriteNoAlert" />

             </Statement>

             <Statement name="WriteScriptLogEntry" continueOnFail="false">

               <Parameter xsi:type="StringParameter" name="Comment" value="Screenshot image #jpegname# stored in Audit / Documents" />

             </Statement>

           </Then>

         </If>

       </Body>

     </Procedure>

    </ScriptExport>

  • Nice job, Craig. But the fact that you folks had to create this to cover yet another failure to provide leaves me thinking, "Good Grief!"

    Now, can you come up with a real Executive Summary Report?  :-)

  • Is there still a way of getting this to work ? i get failed on step 3 line 4