run-as support on Windows


run-as support on Windows enables you to execute any program (.exe ) using a different user account other than the currently logged in user (you). To use this feature, set the following attributes:

  • run-as
  • user-name
  • password
  • wait-for-command-output

Note

run-as support on Windows does not support execution of DOS commands.

Before you begin

The Command Line adapter uses the PsExec utility to support the run-as feature on Windows platforms. To use the run-as feature on Windows, perform the following steps:

  1. Download the PsExec utility that is freely available at http://technet.microsoft.com/hi-in/sysinternals/bb897553(en-us).aspx.
  2. Unbundle the zip file and set the unbundled location to the system's path environment variable.
  3. Restart the grid.

The following table describes the adapter request attributes for the Command Line adapter to support the run-as feature on Windows.

 Command Line adapter request attributes with run-as feature for Windows

The following figure shows a sample adapter request for the Command Line adapter to support the run-as feature on Windows using simple commands.

XML sample of the Command Line adapter request with run-as feature and simple commands format for Windows


<command-request>
 <commands>
   <command run-as="true" user-name="admin" password="admin123" wait-for-command-output="true">ipconfig</command>
 </commands>
</command-request>


The following figure shows a sample adapter response for the Command Line adapter to support the run-as feature on Windows using simple commands.

XML sample of the Command Line adapter response with run-as feature and simple commands format for Windows


<command-result>
 <metadata>
   <status>success</status>
 </metadata>
 <targets-output>
   <target-output>
     <metadata>
       <os-id>Windows XP</os-id>
       <os-version>5.1</os-version>
       <os-arch>x86</os-arch>
       <status>success</status>
     </metadata>
     <commands-output>
       <command-output>
         <metadata>
           <command>ipconfig</command>
           <line-count>34</line-count>
           <execution-milliseconds>0</execution-milliseconds>
           <exit-code>0</exit-code>
           <status>success</status>
         </metadata><output>
           <line index="1"></line>
           <line index="2"></line>
           <line index="3">Windows IP Configuration</line>
           <line index="4"></line>
           <line index="5"></line>
           <line index="6"></line>
           <line index="7"></line>
           <line index="8"></line>
           <line index="9">Ethernet adapter Local Area Connection:</line>
           <line index="10"></line>
           <line index="11"></line>
           <line index="12"></line>
           <line index="13">        Connection-specific DNS Suffix  . : bmc.com
           </line>
           <line index="14"></line>
           <line index="15">        IP Address. . . . . . . . : 10.128.249.29
           </line>
           <line index="16"></line>
           <line index="17">        Subnet Mask . . . . . . . : 255.255.254.0
           </line>
           <line index="18"></line>
           <line index="19">        Default Gateway . . . . . . . . . : 10.128.248.1
           </line>
           <line index="20"></line>
           <line index="21"></line>
           <line index="22"></line>
           <line index="23">Ethernet adapter {EDE30461-C964-4723-863B-AD7D4CFE4886}:
           </line>
           <line index="24"></line>
           <line index="25"></line>
           <line index="26"></line>
           <line index="27">        Connection-specific DNS Suffix  . :
           </line>
           <line index="28"></line>
           <line index="29">        IP Address. . . . . . . . . . . . : 0.0.0.0
           </line>
           <line index="30"></line>
           <line index="31">        Subnet Mask . . . . . . . . . . . : 0.0.0.0
           </line>
           <line index="32"></line>
           <line index="33">        Default Gateway . . . . . . . . . :
           </line>
           <line index="34"></line>
         </output>
       </command-output>
   </commands-output>
    </target-output>
    </targets-output>
  </command-result> 

XML sample of the Command Line adapter request with run-as feature and command group format for Windows


<command-request>
 <commands>
   <command-group>
    <command run-as="true" user-name="guest2" password="abc123">notepad.exe</command>
   </command-group>
 </commands>
</command-request>

The following figure shows a sample adapter response for the Command Line adapter to support the run-as feature on Windows using a command group.

XML sample of the Command Line adapter response with run-as feature and command group format for Windows


<command-result>
 <metadata>
   <status>success</status>
 </metadata>
 <targets-output>
   <target-output>
     <metadata>
       <os-id>Windows XP</os-id>
       <os-version>5.1</os-version>
       <os-arch>x86</os-arch>
       <status>success</status>
     </metadata>
     <commands-output>
       <command-output>
         <metadata>
           <command>notepad.exe</command>
           <line-count>24</line-count>
           <execution-milliseconds>0</execution-milliseconds>
           <exit-code>0</exit-code>
           <status>success</status>
         </metadata>
         <output>
           <line index="1"></line>
           <line index="2">PsExec v1.97 - Execute processes remotely</line>
           <line index="3">Copyright (C) 2001-2009 Mark Russinovich</line>
           <line index="4">Sysinternals - www.sysinternals.com</line>
           <line index="5"></line>
           <line index="6">Access is denied.</line>
           <line index="7">Connecting to 127.0.0.1...</line>
           <line index="8"></line>
           <line index="9"></line>
           <line index="10">Couldn't access 127.0.0.1:</line>
           <line index="12"></line>
           <line index="13"></line>
           <line index="14">Starting PsExec service on 127.0.0.1...</line>
           <line index="15"></line>
           <line index="16"></line>
           <line index="17">Connecting with PsExec service on 127.0.0.1...</line>
           <line index="18"></line>
           <line index="19"></line>
           <line index="20">Starting notepad on 127.0.0.1...</line>
           <line index="21"></line>
           <line index="22"></line>
           <line index="23"></line>
           <line index="24">notepad started on 127.0.0.1 with process ID 4912.</line>
         </output>
       </command-output>
     </commands-output>
   </target-output>
 </targets-output>
</command-result>

The following figure shows a sample adapter request for the Command Line adapter to support the run-as feature on Windows using FAT commands.

XML sample of the Command Line adapter request with run-as feature and FAT command format for Windows


<command-request>
 <commands>
   <fat-command>
     <command os-id="Windows XP"run-as="true" user-name="admin" password="admin123" wait-for-command-output="false">ipconfig</command>
   </fat-command>
 </commands>
</command-request>


The following figure shows a sample adapter response for the Command Line adapter to support the run-as feature on Windows using FAT commands.

XML sample of the Command Line adapter response for the run-as feature and FAT command format for Windows


<command-result>
 <metadata>
   <status>success</status>
 </metadata>
 <targets-output>
   <target-output>
     <metadata>
       <os-id>Windows XP</os-id>
       <os-version>5.1</os-version>
       <os-arch>x86</os-arch>
       <status>success</status>
     </metadata>
<commands-output>
       <command-output>
         <metadata>
           <command>ipconfig</command>
           <line-count>19</line-count>
           <execution-milliseconds>0</execution-milliseconds>
           <exit-code>0</exit-code>
           <status>success</status>
         </metadata>
         <output>
           <line index="1"></line>
           <line index="2">PsExec v1.97 - Execute processes remotely</line>
           <line index="3">Copyright (C) 2001-2009 Mark Russinovich</line>
           <line index="4">Sysinternals - www.sysinternals.com</line>
           <line index="5"></line>
           <line index="6">Connecting to 127.0.0.1...</line>
           <line index="7"></line>
           <line index="8"></line>
           <line index="9">Starting PsExec service on 127.0.0.1...</line>
           <line index="10"></line>
           <line index="11"></line>
           <line index="12">Connecting with PsExec service on 127.0.0.1...</line>
           <line index="13"></line>
           <line index="14"></line>
           <line index="15">Starting ipconfig on 127.0.0.1...</line>
           <line index="16"></line>
           <line index="17"></line>
           <line index="18"></line>
           <line index="19">ipconfig started on 127.0.0.1 with process ID 4812.</line>
         </output>
       </command-output>
     </commands-output>
   </target-output>
 </targets-output>
</command-result>
<command-result>
 <metadata>
   <status>success</status>
 </metadata>
 <targets-output>
   <target-output>
     <metadata>
       <os-id>Windows XP</os-id>
       <os-version>5.1</os-version>
       <os-arch>x86</os-arch>
       <status>success</status>
     </metadata>
<commands-output>
       <command-output>
         <metadata>
           <command>ipconfig</command>
           <line-count>19</line-count>
           <execution-milliseconds>0</execution-milliseconds>
           <exit-code>0</exit-code>
           <status>success</status>
         </metadata>
         <output>
           <line index="1"></line>
           <line index="2">PsExec v1.97 - Execute processes remotely</line>
           <line index="3">Copyright (C) 2001-2009 Mark Russinovich</line>
           <line index="4">Sysinternals - www.sysinternals.com</line>
           <line index="5"></line>
           <line index="6">Connecting to 127.0.0.1...</line>
           <line index="7"></line>
           <line index="8"></line>
           <line index="9">Starting PsExec service on 127.0.0.1...</line>
           <line index="10"></line>
           <line index="11"></line>
           <line index="12">Connecting with PsExec service on 127.0.0.1...</line>
           <line index="13"></line>
           <line index="14"></line>
           <line index="15">Starting ipconfig on 127.0.0.1...</line>
           <line index="16"></line>
           <line index="17"></line>
           <line index="18"></line>
           <line index="19">ipconfig started on 127.0.0.1 with process ID 4812.</line>
         </output>
       </command-output>
     </commands-output>
   </target-output>
 </targets-output>
</command-result>

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*