Package com.thortech.xl.util.adapters
Class tcUtilPSTools
java.lang.Object
com.thortech.xl.util.adapters.tcUtilPSTools
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 Summary
ConstructorsConstructorDescriptionCreates a new tcUtilPSTools object.tcUtilPSTools
(String admin, String adminPwd, String adminDomain, String compName) Constructs tcUtilPSTools object with the following parameters -
Method Summary
Modifier and TypeMethodDescriptionaddUserToFolder
(String batchPath, String batchFileName, String sharePath, String user, String permissions) Adds a user to have access to the directory (Security tab under folder properties)createDirectory
(String batchPath, String batchFileName, String newDir) Creates a directory on the target machinecreateShare
(String batchPath, String batchFileName, String shareName, String sharePath, boolean hidden) Creates a share on the target machinedeleteDirectory
(String batchPath, String batchFileName, String dir) Deletes a directory on the target machinedeleteShare
(String batchPath, String batchFileName, String shareName) Deletes a share on the target machinestatic String
Executes the specified string command in a separate processremoveUserFromFolder
(String batchPath, String batchFileName, String sharePath, String user) Removes a user from having access to the directory (Security tab under folder properties)renameDirectory
(String batchPath, String batchFileName, String existingDirPath, String newDirName) Re-names an existing directory on the target machine RENAME [drive:][path]filename1 filename2.
-
Constructor Details
-
tcUtilPSTools
public tcUtilPSTools()Creates a new tcUtilPSTools object. -
tcUtilPSTools
Constructs tcUtilPSTools object with the following parameters- Parameters:
admin
- Administrator login to use to access remote machineadminPwd
- Administrator password to use with the login to access remote machineadminDomain
- The domain under which the target computer iscompName
- Target computer name
-
-
Method Details
-
createDirectory
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 FilenewDir
- The absolute path of the directory to be created- Returns:
- The error code as a string
-
deleteDirectory
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 Filedir
- 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 FileexistingDirPath
- 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
-
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 FilesharePath
- The path of the directoryuser
- The user to add to the folder,... format: DOMAIN\User, Userpermissions
- 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 FilesharePath
- The path of the directoryuser
- The user to remove from the folder,... format: DOMAIN\User, User- Returns:
- The error code as a string
-
exec
Executes the specified string command in a separate process- Parameters:
command
- command to execute
-