Skip to content

Sys_SetFileAssociation

Sets the file association for a file extension. The function registers the extension in HKEY_CLASSES_ROOT and adds the command for the action.

If the extension is already registered and bOverwriteExisting is False, the function doesn’t change anything, writes this to the package log, and returns True.

Sys_SetFileAssociation(sExtenstion, sAction, sCommand, bOverwriteExisting) As Boolean

File extension, with or without the leading dot, for example .log

The action to create, for example Open

The command to execute when the action is activated

True overwrites the association if it already exists

'Program.exe takes a file as a launch parameter which is supplied by Windows by %1
If bStatus Then bStatus = Sys_SetFileAssociation(".extension", "Open", gsProgramFiles & "\Program\Program.exe %1", True)

Scripting Guidelines

Constants Package Property Variables