Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


Can WinBatch associate files

Keywords: 	   file associate file associations

Question:

Can WinBatch associate files? Example: If I have a Perl Script File on my machine and I double click on it, NT will pop up the window asking me which application I want to use to open this file. I can then pick PERL.EXE to associate this type of file extension with the Perl.exe.

Can WinBatch do that?

Answer:

Yes.

Sample code from FileMenu...

a="xyz"   ; LOWERCASE extension to associate
Terminate((a=="exe"||a=="com"||a=="bat"||a=="pif"||a=="lnk"),"Ooops","Cannot associate executable files")
b=AskFileName("Associate %a% files with","C:\","Executable Files|*.exe;*.com;*.bat;*.pif|All Files|*.*|","",1)

rkey=RegOpenKey(@REGCLASSES,"")
ErrorMode(@OFF)
RegDeleteKey(rkey,".%a%")
ErrorMode(@CANCEL)
RegSetValue(rkey, ".%a%", "%a%_auto_file")
RegSetValue(rkey,"%a%_auto_file\shell\open\command",strcat('"',b,'" "%%1"'))
AU=StrUpper(a)
RegSetValue(rkey,"%a%_auto_file","%AU% File")
RegClosekey(rkey)

        


Article ID:   W14457
Filename:   Can WinBatch associate files.txt