com.denova.runtime
Class WindowsCommands
java.lang.Object
|
+--com.denova.runtime.WindowsCommands
- All Implemented Interfaces:
- WindowsConstants
- public class WindowsCommands
- extends java.lang.Object
- implements WindowsConstants
Provides access to the system path, setting permissons, etc.
- Author:
- DeNova
Copyright © 1997-2008 DeNova
All rights reserved worldwide.
| Fields inherited from interface com.denova.runtime.WindowsConstants |
AddRegistryEntry, AllUsers, AppendRegistryEntry, BinaryType, CurrentUser, DeleteRegistryEntry, DesktopSpecFilename, DirectoryResultsFilename, DWordType, EnumKeyRegistryEntry, EnumValueRegistryEntry, EnvOutputFilename, ExistsRegistryEntry, FreeDiskSpaceResultsFilename, InvokerFilename, MenuSpecFilename, NtResultsFilename, PathOutputFilename, PrependRegistryEntry, QueryRegistryEntry, RegistryResultsFilename, RegistrySpecFilename, ReplaceRegistryEntry, ShortnameFilename, StringType, WindowsAddDesktop, WindowsAddProgramsMenu, WindowsAddStartupMenu, WindowsAppDataCommand, WindowsCmdLogFilename, WindowsCommandsFilename, WindowsDelDesktop, WindowsDelProgramsMenu, WindowsDelStartupMenu, WindowsDesktopCommand, WindowsDesktopDirCommand, WindowsDirCommand, WindowsEnvVariableCommand, WindowsFreeDiskSpaceCommand, WindowsMenusDirCommand, WindowsNtCommand, WindowsPathCommand, WindowsPathShortenerCommand, WindowsProgramManagerDirCommand, WindowsProgramsMenuCommand, WindowsRegistryEditorCommand, WindowsStartupMenuCommand, WindowsStartupMenusDirCommand |
|
Method Summary |
static boolean |
changePermissions(java.lang.String filename,
java.util.List args)
Change the permissions on a file using attrib. |
static java.lang.String |
getAncientShortPath(java.lang.String path)
Get the Windows short name for a file or directory. |
static java.lang.String[] |
getEnvironment()
Get the environment. |
static java.lang.String |
getEnvVariable(java.lang.String variable)
Get the value of the environment variable. |
static java.lang.Long |
getFreeDiskSpace(java.lang.String rootPath)
Get the free space on the drive. |
static java.lang.String |
getSystemPath()
Get the system's path. |
static void |
main(java.lang.String[] args)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
WindowsCommands
public WindowsCommands()
getSystemPath
public static java.lang.String getSystemPath()
- Get the system's path.
- Returns:
- string with the full path or null if unable to obtain path.
getEnvVariable
public static java.lang.String getEnvVariable(java.lang.String variable)
- Get the value of the environment variable.
- Returns:
- string with the value of the environment varialbe.
getEnvironment
public static java.lang.String[] getEnvironment()
- Get the environment.
- Returns:
- the environment or null if unable to obtain it.
changePermissions
public static boolean changePermissions(java.lang.String filename,
java.util.List args)
- Change the permissions on a file using attrib.
Valid args:
+r : Sets the read-only file attribute.
-r : Clears the read-only file attribute.
+a : Sets the archive file attribute.
-a : Clears the archive file attribute.
+s : Sets the system file attribute.
-s : Clears the system file attribute.
+h : Sets the hidden file attribute.
-h : Clears the hidden file attribute.
/s : Applies attrib and any command-line options to matching files in the current directory and all of its subdirectories.
/d : Applies attrib and any command-line options to directories. (only available on XP and 2000)
- Parameters:
filename - full path to file.args - list of stringarguments to attrib.
- Returns:
- true if successful issuing command. The return
value does not tell you if the change permissions
worked or not.
getFreeDiskSpace
public static java.lang.Long getFreeDiskSpace(java.lang.String rootPath)
- Get the free space on the drive.
- Parameters:
rootPath - The drive's top level path.
- Returns:
- the number of bytes free or -1 if unable to get the information
getAncientShortPath
public static java.lang.String getAncientShortPath(java.lang.String path)
- Get the Windows short name for a file or directory.
If short names aren't supported, then returns the original path.
If any errors occur while getting the name, returns null.
- Parameters:
path - the full path of a file or directory.
- Returns:
- the short name or null if not successful.
main
public static void main(java.lang.String[] args)