com.denova.runtime
Class WindowsCommands

java.lang.Object
  extended by 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
© 1997-2011 DeNova
Last modified: 2011-06-23

Field Summary
 
Fields inherited from interface com.denova.runtime.WindowsConstants
AddRegistryEntry, AllUsers, ArchitectureAMD64, ArchitectureIA64, ArchitectureIntel, ArchitectureUnknown, ArchitectureX64, ArchitectureX86, ArchitectureX86_64, BinaryType, CurrentUser, DeleteAttribute, DeleteRegistryEntry, DesktopSpecFilename, DWordType, ExecExtension, InvokerFilename, MenuSpecFilename, RegistrySpecFilename, ReplaceRegistryEntry, StringType, WindowsCleanupCommand, WindowsCmdLogFilename, WindowsDelDesktop, WindowsDelProgramsMenu, WindowsDelStartupMenu, WindowsProgramsMenuCommand, WindowsRegistryEditorCommand
 
Constructor Summary
WindowsCommands()
           
 
Method Summary
static boolean changePermissions(java.lang.String filename, java.util.List args)
          Change the permissions on a file using attrib.
static boolean createLink(java.lang.String existingFilename, java.lang.String linkedFilename)
          Create a link between 2 files.
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 a single valued environment variable.
static java.lang.Long getFreeDiskSpace(java.lang.String rootPath)
          Get the free space on the drive.
static java.lang.String getProcessorArchitecture()
          Get the architecture of the processor.
static java.lang.String getSystemPath()
          Get the system's path.
static boolean hideFile(java.lang.String filename)
          Hide the file or directory.
static boolean is64BitProcessorArchitecture()
          Determine if the OS is 64 bit.
static boolean isWow64Process()
          Is this program is running as a 32 bit process on a 64 bit OS.
static boolean normalFile(java.lang.String filename)
          Set the file or folder attributes to normal.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WindowsCommands

public WindowsCommands()
Method Detail

createLink

public static boolean createLink(java.lang.String existingFilename,
                                 java.lang.String linkedFilename)
Create a link between 2 files. You can not make a link to or from a directory.
If the linkedFilename exists before this routine is called, it is erased.

Parameters:
existingFilename - file to create a link to
linkedFilename - symbolically linked file

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 a single valued 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.

getProcessorArchitecture

public static java.lang.String getProcessorArchitecture()
Get the architecture of the processor. See WindowsConstants for the architecture names returned by this method.

Returns:
string with the architecture of the processor.

is64BitProcessorArchitecture

public static boolean is64BitProcessorArchitecture()
Determine if the OS is 64 bit.

Returns:
true if OS is 64 bit.

isWow64Process

public static boolean isWow64Process()
Is this program is running as a 32 bit process on a 64 bit OS.

Returns:
true if this program is running as a 32 bit process on a 64 bit OS.

changePermissions

public static boolean changePermissions(java.lang.String filename,
                                        java.util.List args)
Change the permissions on a file using attrib. Standard 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. You can pass any extended arg if the underlying version of Windows supports it.

Parameters:
filename - full path to file.
args - list of string arguments to attrib.
Returns:
true if successful issuing command. The return value does not tell you if the change permissions worked or not.

hideFile

public static boolean hideFile(java.lang.String filename)
Hide the file or directory. If the filename is a directory, then also hides all subdirectories and files.

Parameters:
filename - full path to the file or folder to hide.

normalFile

public static boolean normalFile(java.lang.String filename)
Set the file or folder attributes to normal.

Parameters:
filename - full path to file or folder to set attributes to normal.

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.