Class tcUtilPSTools

java.lang.Object
com.thortech.xl.util.adapters.tcUtilPSTools

public class tcUtilPSTools extends Object
This is a wrapper class utilizing PSTools utility released by sysinternals.com. It based on executing a batch files remotely using psexec.exe provided by PSTools. It assumes this executable is in the system path. The paths and names of the associated batch files should be provided.
Author:
Stanislav Sadykov
  • Constructor Details

    • tcUtilPSTools

      public tcUtilPSTools()
      Creates a new tcUtilPSTools object.
    • tcUtilPSTools

      public tcUtilPSTools(String admin, String adminPwd, String adminDomain, String compName)
      Constructs tcUtilPSTools object with the following parameters
      Parameters:
      admin - Administrator login to use to access remote machine
      adminPwd - Administrator password to use with the login to access remote machine
      adminDomain - The domain under which the target computer is
      compName - Target computer name
  • Method Details

    • createDirectory

      public String createDirectory(String batchPath, String batchFileName, String newDir)
      Creates a directory on the target machine
      Parameters:
      batchPath - The absolute path of the batch file(without the '\' at the end) on local machine that is to be copied to target machine and executed there.
      batchFileName - The name of the batch File
      newDir - The absolute path of the directory to be created
      Returns:
      The error code as a string
    • deleteDirectory

      public String deleteDirectory(String batchPath, String batchFileName, String dir)
      Deletes a directory on the target machine
      Parameters:
      batchPath - The absolute path of the batch file(without the '\' at the end) on local machine that is to be copied to target machine and executed there.
      batchFileName - The name of the batch File
      dir - The absolute path of the directory to be deleted
      Returns:
      The error code as a string
    • renameDirectory

      public String renameDirectory(String batchPath, String batchFileName, String existingDirPath, String newDirName)
      Re-names an existing directory on the target machine RENAME [drive:][path]filename1 filename2. or REN [drive:][path]filename1 filename2. Note that you cannot specify a new drive or path for your destination file.
      Parameters:
      batchPath - The absolute path of the batch file(without the '\' at the end) on local machine that is to be copied to target machine and executed there.
      batchFileName - The name of the batch File
      existingDirPath - The absolute path of the directory to be deleted, ex: "c:\dirOld"
      newDirName - The new directory name, ex: "dirNew"
      Returns:
      The error code as a string
    • createShare

      public String createShare(String batchPath, String batchFileName, String shareName, String sharePath, boolean hidden)
      Creates a share on the target machine
      Parameters:
      batchPath - The absolute path of the batch file(without the '\' at the end) on local machine that is to be copied to target machine and executed there.
      batchFileName - The name of the batch File
      shareName - Share name of the sharing directory
      sharePath - Absolute path of the sharing directory
      hidden - true is the share is hidden, false otherwise
      Returns:
      The error code as a string
    • deleteShare

      public String deleteShare(String batchPath, String batchFileName, String shareName)
      Deletes a share on the target machine
      Parameters:
      batchPath - The absolute path of the batch file(without the '\' at the end) on local machine that is to be copied to target machine and executed there.
      batchFileName - The name of the batch File
      shareName - Share name (that is to be deleted) of the shared directory
      Returns:
      The error code as a string
    • addUserToFolder

      public String addUserToFolder(String batchPath, String batchFileName, String sharePath, String user, String permissions)
      Adds a user to have access to the directory (Security tab under folder properties)
      Parameters:
      batchPath - The absolute path of the batch file(without the '\' at the end) on local machine that is to be copied to target machine and executed there.
      batchFileName - The name of the batch File
      sharePath - The path of the directory
      user - The user to add to the folder,... format: DOMAIN\User, User
      permissions - The permissions to the folder of the user added, (format: ":F", ":C", ... for Full Control, Change, ... permissions)
      Returns:
      The error code as a string
    • removeUserFromFolder

      public String removeUserFromFolder(String batchPath, String batchFileName, String sharePath, String user)
      Removes a user from having access to the directory (Security tab under folder properties)
      Parameters:
      batchPath - The absolute path of the batch file(without the '\' at the end) on local machine that is to be copied to target machine and executed there.
      batchFileName - The name of the batch File
      sharePath - The path of the directory
      user - The user to remove from the folder,... format: DOMAIN\User, User
      Returns:
      The error code as a string
    • exec

      public static String exec(String command)
      Executes the specified string command in a separate process
      Parameters:
      command - command to execute