Inspired by Glenn's Associate() UDF and by the MS article referenced in the comments I altered the Associate UDF a bit (hope you don't mind Glenn \:\) ) to create file associations on a per user basis. It sets the association in hkcu\software\classes so it can be used in a logon script. A per user file association will override a per machine file association.

I would like to hear suggestion/comments/whatever from you guys before posting it in the UDF forum.


 Code:
;FUNCTION Associate2()
;
;ACTION:
;	Associates a per user file extension with a particular action.
;	A per use file association overrides the one set per system.
;
;AUTHOR:
;	Mart
;	Based on the Associate UDF by Glenn Barnas.
;	Inspired by: http://support.microsoft.com/kb/257592
;
;SYNTAX:
;	Associate2(extension, type, description, open, edit, icon)
;
;PARAMETERS:
;	Extension (required)
;		File extension to associate.
;
;	Type (required)
;		Short FileType description.
;
;	Description (required)
;		Description of File Type.
;
;	Open Command (required)
;		Command to Open (Execute) the associated file.
;
;	Edit Command (optional)
;		Command to EDIT the associated file.
;
;	Icon (optional)
;		Default icon for the specific filetype.
;		Can either be a .ico file or something like shell32.dll,3 (third icon in shell32.dll).
;		If none is given the default icon for unknown file types is used by windows.
;
;Remarks:
;	Should work with Windows 2000 and up.
;	Developed and tested on Windows XP SP2 and Kix4.60.
;
;RETURNS:
;	System error codes.
;
;DEPENDENCIES:
;	None
;
;EXAMPLES:
;	;Define a new association to open (execute) and edit .kix files and set an icon.
;		Associate2(".kix", "KixScript", "Kixtart Script", "Kix32.exe", "notepad.exe", "c:\someicon.ico")
;
Function Associate2($extension, $type, $description, $opencmd, optional $editcmd, $icon)

	Dim $rc

	;Make sure the dot is specified.
	If Left($extension, 1) <> "."
		$extension = "." + $extension
	EndIf
	
	;Exit if a required parameter is empty.
	Select
		Case $extension = ""
			Exit 87
		Case $type = ""
			Exit 87
		Case $description = ""
			Exit 87
		Case $opencmd = ""
			Exit 87
	EndSelect

	;Set file type and description.
	$rc = WriteValue("HKCU\SOFTWARE\Classes\" + $extension, "", $type, "REG_SZ")
	$rc = WriteValue("HKCU\SOFTWARE\Classes\" + $extension + "\" + $type, "", $description, "REG_SZ")
	
	;Create the values for the open command.
	$rc = WriteValue("HKCU\SOFTWARE\Classes\" + $extension + "\Shell\Open\Command", "", $opencmd, "REG_EXPAND_SZ")
	
	;Create the definitions for the edit command.
	If $editcmd <> ""
		$rc = WriteValue("HKCU\SOFTWARE\Classes\" + $extension + "\Shell\Edit\Command", "", $editcmd, "REG_EXPAND_SZ")
	EndIf
	
	;Set icon.
	If $icon <> ""
		$rc = WriteValue("HKCU\SOFTWARE\Classes\" + $extension + "\DefaultIcon", "", $icon, "REG_SZ")
	EndIf
	
	
	If @ERROR = 0
		$Asssociate2 = 0
	Else
		$Asssociate2 = @ERROR
	EndIf
EndFunction


Edited by Mart (2008-01-28 11:04 PM)
Edit Reason: Typo: His name is Glenn and not Gelnn.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.