Next Topic

Previous Topic

Book Contents

executeShellCommand()

Allows the procedure to pass commands to the command interpreter on the managed machine. When this command is selected, the field Enter the command to execute in a command shell is displayed. Enter a command in the field. The command must be syntactically correct and executable with the OS version on the managed machine. Commands and parameters containing spaces should be surrounded by quotes. Since the command is executed relative to the agent directory, absolute paths should be used when entering commands.

Note: executeShellCommand() opens a command prompt window on a managed Windows machine to execute in. If you do not want a window opening on a managed Windows machine, because it might confuse users, put all the commands in a batch file. Send that file to the managed Windows machine using the writeFile() command. Then run the batch file with the executeFile() command. executeFile() does not open a window on a managed Windows machine.

If Execute as the logged on user is selected, then a credential must be specified by running either the impersonateUser() or useCredential() command before this command. If run Execute as the system account is selected, execution is restricted to the agent's system level access.

Example - Sample Procedures.Agent Control.Remove K Menu

executeShellCommand("rmdir "%ALLUSERSPROFILE%\Start Menu\Programs\Kaseya" /S /Q", "Execute as System", "Windows 8.1", "Halt on Fail")