Package com.install4j.api.windows
Class WinFileSystem
- java.lang.Object
-
- com.install4j.api.windows.WinFileSystem
-
public class WinFileSystem extends java.lang.ObjectCollection of static methods to access Microsoft Windows-specific folder locations and to execute native file system operations.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleancreateShellLink(java.io.File file, java.io.File shortcutTo, java.io.File iconFile)Creates a shell link.static booleancreateShellLink(java.io.File file, java.io.File shortcutTo, java.io.File iconFile, java.lang.String arguments)Creates a shell link.static booleancreateShellLink(java.io.File file, java.io.File shortcutTo, java.io.File iconFile, java.lang.String arguments, java.lang.String description)Creates a shell link.static booleancreateShellLink(java.io.File file, java.io.File shortcutTo, java.io.File iconFile, java.lang.String arguments, java.lang.String description, java.io.File startIn)Creates a shell link.static booleancreateShellLink(java.io.File file, java.io.File shortcutTo, java.io.File iconFile, java.lang.String arguments, java.lang.String description, java.io.File startIn, ShowCommand showCommand)Creates a shell link.static voidcreateStartMenuEntry(java.lang.String programGroupName, java.lang.String entryName, java.io.File destination, boolean allUsers, java.io.File icon)Creates a start menu entry.static voidcreateStartMenuEntry(java.lang.String programGroupName, java.lang.String entryName, java.io.File destination, boolean allUsers, java.io.File icon, java.lang.String arguments)Creates a start menu entry.static voidcreateStartMenuEntry(java.lang.String programGroupName, java.lang.String entryName, java.io.File destination, boolean allUsers, java.io.File icon, java.lang.String arguments, boolean runAsAdministrator)Creates a start menu entry.static java.io.FilegetCommonFilesDirectory()Returns a folder for components that are shared across applications.static DriveTypegetDriveType(java.io.File file)Tests on what kind of drive the given file is (or would be) located.static java.io.FilegetProgramDataDirectory()Returns the program data directory where applications can save data that is not specific to particular users.static java.io.FilegetProgramFilesDirectory()Returns the program files directory of the current Windows installation.static java.io.FilegetSpecialFolder(SpecialFolder folderType, boolean allUsers)Returns Windows-specific directories like the start menu or the desktop.static java.io.FilegetSystemDirectory()Returns the system directory.static java.io.FilegetWindowsDirectory()Returns the Windows directory.static booleanmoveWithDelayUntilReboot(java.io.File source, java.io.File destination)Calls the win32 API function MoveFileEx with MOVEFILE_DELAY_UNTIL_REBOOT.
-
-
-
Method Detail
-
getSpecialFolder
public static java.io.File getSpecialFolder(SpecialFolder folderType, boolean allUsers)
Returns Windows-specific directories like the start menu or the desktop.- Parameters:
folderType- specifies the requested folder type.allUsers- if this parameter istrueand if the current user is in the Administrators group, the method returns the requested folder for all users. Otherwise it returns the folder for the current user.- Returns:
- the requested folder location.
-
getProgramFilesDirectory
public static java.io.File getProgramFilesDirectory()
Returns the program files directory of the current Windows installation. A typical path isC:\Program Files.- Returns:
- the program files directory.
-
getCommonFilesDirectory
public static java.io.File getCommonFilesDirectory()
Returns a folder for components that are shared across applications. A typical path isC:\Program Files\Common Files.- Returns:
- the common files directory.
-
getProgramDataDirectory
public static java.io.File getProgramDataDirectory()
Returns the program data directory where applications can save data that is not specific to particular users. A typical path isC:\ProgramData.- Returns:
- the common files directory.
-
getWindowsDirectory
public static java.io.File getWindowsDirectory()
Returns the Windows directory. A typical path isC:\Windows.- Returns:
- the Windows directory.
-
getSystemDirectory
public static java.io.File getSystemDirectory()
Returns the system directory. A typical path isC:\Windows\system32- Returns:
- the system directory.
-
createShellLink
public static boolean createShellLink(java.io.File file, java.io.File shortcutTo, java.io.File iconFile)Creates a shell link. Note that Windows might change the link suffix fromlnktopif, if you are linking to a DOS executable or a batch file. This as the same as callingcreateShellLink(file, shortcutTo, iconFile, null, null)- Parameters:
file- the shell link that should be created including thelnksuffix.shortcutTo- the file it should link to.iconFile- an optional icon file. Ifnullis passed, the default icon of theshortcutTotarget will be used.- Returns:
- whether the link could be created or not.
- See Also:
createShellLink(File, File, File, String)
-
createShellLink
public static boolean createShellLink(java.io.File file, java.io.File shortcutTo, java.io.File iconFile, java.lang.String arguments)Creates a shell link. Note that Windows might change the link suffix fromlnktopif, if you are linking to a DOS executable or a batch file. This as the same as callingcreateShellLink(file, shortcutTo, iconFile, arguments, null)- Parameters:
file- the shell link that should be created including thelnksuffix.shortcutTo- the file it should link to.iconFile- an optional icon file. Ifnullis passed, the default icon of theshortcutTotarget will be used.arguments- the arguments passed to the target.- Returns:
- whether the link could be created or not.
-
createShellLink
public static boolean createShellLink(java.io.File file, java.io.File shortcutTo, java.io.File iconFile, java.lang.String arguments, java.lang.String description)Creates a shell link. Note that Windows might change the link suffix fromlnktopif, if you are linking to a DOS executable or a batch file.- Parameters:
file- the shell link that should be created including thelnksuffix.shortcutTo- the file it should link to.iconFile- an optional icon file. Ifnullis passed, the default icon of theshortcutTotarget will be used.arguments- the arguments passed to the target.description- the description used in the tooltip- Returns:
- whether the link could be created or not.
-
createShellLink
public static boolean createShellLink(java.io.File file, java.io.File shortcutTo, java.io.File iconFile, java.lang.String arguments, java.lang.String description, java.io.File startIn)Creates a shell link. Note that Windows might change the link suffix fromlnktopif, if you are linking to a DOS executable or a batch file.- Parameters:
file- the shell link that should be created including thelnksuffix.shortcutTo- the file it should link to.iconFile- an optional icon file. Ifnullis passed, the default icon of theshortcutTotarget will be used.arguments- the arguments passed to the target.description- the description used in the tooltipstartIn- the working directory for the executable- Returns:
- whether the link could be created or not.
-
createShellLink
public static boolean createShellLink(java.io.File file, java.io.File shortcutTo, java.io.File iconFile, java.lang.String arguments, java.lang.String description, java.io.File startIn, ShowCommand showCommand)Creates a shell link. Note that Windows might change the link suffix fromlnktopif, if you are linking to a DOS executable or a batch file.- Parameters:
file- the shell link that should be created including thelnksuffix.shortcutTo- the file it should link to.iconFile- an optional icon file. Ifnullis passed, the default icon of theshortcutTotarget will be used.arguments- the arguments passed to the target.description- the description used in the tooltipstartIn- the working directory for the executableshowCommand- the window show command- Returns:
- whether the link could be created or not.
-
createStartMenuEntry
public static void createStartMenuEntry(java.lang.String programGroupName, java.lang.String entryName, java.io.File destination, boolean allUsers, java.io.File icon) throws java.io.IOExceptionCreates a start menu entry.- Parameters:
programGroupName- the name of the program group where the entry should be createdentryName- the name of the menu entry. You can create subfolders with backslashes.destination- the file that should be linked toallUsers- whether the entry should be created for all users or noticon- an optional icon file. Ifnullis passed, the default icon of thedestinationtarget will be used.- Throws:
java.io.IOException- if the start menu entry could not be created
-
createStartMenuEntry
public static void createStartMenuEntry(java.lang.String programGroupName, java.lang.String entryName, java.io.File destination, boolean allUsers, java.io.File icon, java.lang.String arguments) throws java.io.IOExceptionCreates a start menu entry.- Parameters:
programGroupName- the name of the program group where the entry should be createdentryName- the name of the menu entry. You can create subfolders with backslashes.destination- the file that should be linked toallUsers- whether the entry should be created for all users or noticon- an optional icon file. Ifnullis passed, the default icon of thedestinationtarget will be used.arguments- optional arguments given to the destination. Can benull- Throws:
java.io.IOException- if the start menu entry could not be created
-
createStartMenuEntry
public static void createStartMenuEntry(java.lang.String programGroupName, java.lang.String entryName, java.io.File destination, boolean allUsers, java.io.File icon, java.lang.String arguments, boolean runAsAdministrator) throws java.io.IOExceptionCreates a start menu entry.- Parameters:
programGroupName- the name of the program group where the entry should be createdentryName- the name of the menu entry. You can create subfolders with backslashes.destination- the file that should be linked toallUsers- whether the entry should be created for all users or noticon- an optional icon file. Ifnullis passed, the default icon of thedestinationtarget will be used.arguments- optional arguments given to the destination. Can benullrunAsAdministrator- whether the entry should be run as administrator- Throws:
java.io.IOException- if the start menu entry could not be created
-
moveWithDelayUntilReboot
public static boolean moveWithDelayUntilReboot(java.io.File source, java.io.File destination)Calls the win32 API function MoveFileEx with MOVEFILE_DELAY_UNTIL_REBOOT. You must be administrator to call this function.- Parameters:
source- the source file. Must be on the same drive as the destination file.destination- the destination file. If empty, the source file will be deleted.- Returns:
- true if the operation could be registered successfully.
-
-