public class Windows extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Windows.WindowsDirectories |
Modifier and Type | Field and Description |
---|---|
static int |
SENDMAIL_OPTION_SHOW_DIALOG |
static int |
SHORTCUT_OPTION_USE_EXACT_NAME
An option for createShortcut() - specifies that the name should be
used exactly as is without any attempt to modify it by adding or
changing the extension.
|
static int |
SHORTCUT_RETURN_DESCRIPTION_NOT_USED
A return value for createShortcut() - indicates that the description
was not used because it is not supported by the OS.
|
Constructor and Description |
---|
Windows() |
Modifier and Type | Method and Description |
---|---|
static boolean |
allowAllUsersFullAccess(String fileOrDirectory)
Set a directory or file to allow all users full read/write/delete access.
|
static int |
createShortcut(String targetExe,
String targetArguments,
String shortcutPath,
String description,
int options)
Create a shortcut (link) to a target executable.
|
static String[] |
getNetHostList(String hostName) |
static String[] |
getNetRootList(PropertyList options) |
static Windows.WindowsDirectories |
getWindowsDirectories(boolean doNewLookup) |
static boolean |
isRunningOnWindows()
Check if the current platform is Windows NT based (i.e.
|
static void |
mapiSendMail(String subject,
String[] recipients,
String[] attachments,
String mailText,
int sendMailOptions)
Attempt to send an e-mail with possible attachments via MAPI.
|
static Handle |
netListComputers(PropertyList options) |
static void |
notifyFolderChange(String folderName)
Notify the Windows shell that the contents of a folder has changed.
|
static void |
notifyShellAssociationChange()
Notify the Windows shell that file associations have changed.
|
static boolean |
programHasAdminRights()
Check if the running program has Administrator privileges.
|
static String |
quoteIfOnWindows(String toQuote,
boolean removeExistingQuotes)
This will put double quotes around a String if the current program is running on Windows.
|
static Process |
runAsAdministrator(String filePath,
String parameters,
String workingDirectory)
Run an application with full administrator rights - which will cause on Vista/7 a dialog box to appear to confirm that
the user will allow it.
|
static Process |
shellExecute(String filePath,
String verb,
String parameters,
String workingDirectory)
Perform a ShellExecute() on a file.
|
static void |
testMapiSendMail()
Test if the MapiSendMail interface is present on the system.
|
public static final int SHORTCUT_OPTION_USE_EXACT_NAME
public static final int SHORTCUT_RETURN_DESCRIPTION_NOT_USED
public static final int SENDMAIL_OPTION_SHOW_DIALOG
public static Windows.WindowsDirectories getWindowsDirectories(boolean doNewLookup)
public static int createShortcut(String targetExe, String targetArguments, String shortcutPath, String description, int options) throws IOException
targetExe
- the full path to the target executable.targetArguments
- the full argument string to pass to the executable.shortcutPath
- the full path to the created shortcut.description
- a user description for the shortcut.options
- any of the SHORTCUT_OPTION_XXX values OR'ed together.IOException
- if it could not be created.public static void mapiSendMail(String subject, String[] recipients, String[] attachments, String mailText, int sendMailOptions) throws IOException
subject
- an optional subject.recipients
- an optional list of recipients as e-mail addresses.attachments
- an optional list of files each of the form: "mailText
- the optional mail text.sendMailOptions
- any combination of the SENDMAIL_OPTION_XXX values.IOException
- if mail sending failed for any reason.public static void testMapiSendMail() throws IOException
IOException
- if the MAPI library could not be loaded.public static boolean isRunningOnWindows()
public static String quoteIfOnWindows(String toQuote, boolean removeExistingQuotes)
toQuote
- the text to quote.removeExistingQuotes
- if this is true then existing quotes are removed if not running under Windows. Otherwise the quotes will be left.public static boolean programHasAdminRights()
public static Process runAsAdministrator(String filePath, String parameters, String workingDirectory) throws IOException
filePath
- the full path to the executable.parameters
- an optional parameter string to pass to the executable.workingDirectory
- an optional working directory to set for the executable.IOException
- on an error or if the user denies the request.public static Process shellExecute(String filePath, String verb, String parameters, String workingDirectory) throws IOException
filePath
- the full path to the file.verb
- a standard ShellExecute verb such as "open", "explore", "edit", "print".parameters
- for "open" on an executable this will be optional parameters to pass to the executable.workingDirectory
- for "open" on an executable this will be an optional working directory.IOException
- on failure.public static boolean allowAllUsersFullAccess(String fileOrDirectory) throws IOException
fileOrDirectory
- the name of the file or directory.IOException
- on an IO error.public static void notifyShellAssociationChange()
public static void notifyFolderChange(String folderName)
public static Handle netListComputers(PropertyList options)
public static String[] getNetRootList(PropertyList options)