lafafmentvotre Posted February 2, 2011 Share Posted February 2, 2011 Hi everybody First, sorry for my bad english. I need to convert this batch in a au3 file : @Echo off Set "cmpn=7z#0 arj#4 bz2#2 bzip2#2 cab#7 cpio#12 deb#11 dmg#17 fat#21 gz#14 gzip#14 hfs#18 iso#8 lha#6 lzh#6 lzma#16 ntfs#22 rar#3 rpm#10 split#9 swm#15 tar#13 taz#5 tbz#2 tbz2#2 tgz#14 tpz#14 vhd#20 wim#15 xar#19 xz#23 z#5 zip#1" For %%I In (%cmpn%) Do For /F "tokens=1* Delims=#" %%a In ("%%I") Do Call :ass_set %%a %%b Exit :ass_set reg add "HKCR\.%1" /ve /t REG_SZ /d "7-Zip.%1" /f>Nul reg add "HKCR\7-Zip.%1" /ve /t REG_SZ /d "%1 Archive" /f>Nul reg add "HKCR\7-Zip.%1\DefaultIcon" /ve /t REG_SZ /d "%PROGRAMFILES%\7-Zip\7z.dll,%2" /f>Nul reg add "HKCR\7-Zip.%1\shell" /ve /t REG_SZ /d "" /f>Nul reg add "HKCR\7-Zip.%1\shell\open" /ve /t REG_SZ /d "" /f>Nul reg add "HKCR\7-Zip.%1\shell\open\command" /ve /t REG_SZ /d "\"%PROGRAMFILES%\7-Zip\7zFM.exe\" \"%%1\"" /f>Nul GoTo :EOF I started this script but I can not interpret the rest "Do For /F "tokens=1* Delims=#" %%a In ("%%I") Do Call :ass_set %%a %%b" #include <file.au3> #include <Array.au3> Local $arraylist="" _FileReadToArray("Liste.txt", $arraylist) _ArrayDisplay($arraylist) For $i=1 to Ubound($arraylist)-1 Do For My file "Liste.txt" contain : 7z#0 arj#4 ... zip#1 Is it possible to help me ? Thanks Link to comment Share on other sites More sharing options...
hannes08 Posted February 2, 2011 Share Posted February 2, 2011 Hi lafafmentvotre, #include <file.au3> #include <Array.au3> Dim $array _FileReadToArray("Liste.txt", $array) For $i=1 to $array[0] _do_something($array[$i]) Next Func _do_something($input) ;Here comes your regadd ... EndFunc Regards, Hannes Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler] Link to comment Share on other sites More sharing options...
lafafmentvotre Posted February 2, 2011 Author Share Posted February 2, 2011 Hi Hannes Thanks for response. It works now #include <file.au3> #include <Array.au3> Dim $array Local $file=FileOpen('Liste.txt', 0) For $i=1 To 33 $array=StringSplit(FileReadLine($file,$i),"#") If @error = -1 Then ExitLoop $archive_type=_ArrayToString($array, @TAB, 1, 1) $switch=_ArrayToString($array, @TAB, 2, 2) RegWrite("HKCR\."&$archive_type,"","REG_SZ",$archive_type&" Archive") RegWrite("HKCR\."&$archive_type&"\DefaultIcon","","REG_SZ","C:\Program Files\7-Zip\7z.dll,"&$switch) RegWrite("HKCR\."&$archive_type&"\shell","","REG_SZ","") RegWrite("HKCR\."&$archive_type&"\shell\open","","REG_SZ","") RegWrite("HKCR\."&$archive_type&"\shell\open\command","","REG_SZ","""C:\Program Files\7-Zip\7zFM.exe"" ""%1""") Next FileClose($file) Link to comment Share on other sites More sharing options...
hannes08 Posted February 2, 2011 Share Posted February 2, 2011 Hey lafafmentvotre, you may want to consider using a while loop for the reading of the text file, just in case it changes sometimes... so instead of: #include <file.au3> #include <Array.au3> Dim $array Local $file=FileOpen('Liste.txt', 0) For $i=1 To 33 $array=StringSplit(FileReadLine($file,$i),"#") If @error = -1 Then ExitLoop $archive_type=_ArrayToString($array, @TAB, 1, 1) $switch=_ArrayToString($array, @TAB, 2, 2) RegWrite("HKCR\."&$archive_type,"","REG_SZ",$archive_type&" Archive") RegWrite("HKCR\."&$archive_type&"\DefaultIcon","","REG_SZ","C:\Program Files\7-Zip\7z.dll,"&$switch) RegWrite("HKCR\."&$archive_type&"\shell","","REG_SZ","") RegWrite("HKCR\."&$archive_type&"\shell\open","","REG_SZ","") RegWrite("HKCR\."&$archive_type&"\shell\open\command","","REG_SZ","""C:\Program Files\7-Zip\7zFM.exe"" ""%1""") Next FileClose($file) Use: #include <file.au3> #include <Array.au3> Dim $array Local $file=FileOpen('Liste.txt', 0) While 1 $array=StringSplit(FileReadLine($file,$i),"#") If @error = -1 Then ExitLoop $archive_type=_ArrayToString($array, @TAB, 1, 1) $switch=_ArrayToString($array, @TAB, 2, 2) RegWrite("HKCR\."&$archive_type,"","REG_SZ",$archive_type&" Archive") RegWrite("HKCR\."&$archive_type&"\DefaultIcon","","REG_SZ","C:\Program Files\7-Zip\7z.dll,"&$switch) RegWrite("HKCR\."&$archive_type&"\shell","","REG_SZ","") RegWrite("HKCR\."&$archive_type&"\shell\open","","REG_SZ","") RegWrite("HKCR\."&$archive_type&"\shell\open\command","","REG_SZ","""C:\Program Files\7-Zip\7zFM.exe"" ""%1""") Wend FileClose($file) Regards, Hannes Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler] Link to comment Share on other sites More sharing options...
lafafmentvotre Posted February 2, 2011 Author Share Posted February 2, 2011 Doesn't work : WARNING: $i: possibly used before declaration. Link to comment Share on other sites More sharing options...
Varian Posted February 2, 2011 Share Posted February 2, 2011 $Extensions = StringSplit('7z#0,arj#4,bz2#2,bzip2#2,cab#7,cpio#12,deb#11,dmg#17,fat#21,gz#14,gzip#14,hfs#18,iso#8,lha#6,lzh#6,lzma#16,ntfs#22,rar#3,rpm#10,split#9,swm#15,tar#13,taz#5,tbz#2,tbz2#2,tgz#14,tpz#14,vhd#20,wim#15,xar#19,xz#23,z#5,zip#1', ',', 2) For $Element In $Extensions $iIndex = StringRegExpReplace($Element, '^.+#', '') $Element = StringRegExpReplace($Element, '#.+$', '') RegWrite('HKCR\.' & $Element, '', 'REG_SZ', '7-Zip.' & $Element) RegWrite('HKCR\7-Zip.' & $Element, '', 'REG_SZ', $Element & ' Archive') RegWrite('HKCR\7-Zip.' & $Element & '\DefaultIcon', '', 'REG_SZ', @ProgramFilesDir & '\7-Zip\7z.dll,' & $iIndex) RegWrite('HKCR\7-Zip.' & $Element & '\shell', '', 'REG_SZ', '') RegWrite('HKCR\7-Zip.' & $Element & '\shell\open', '', 'REG_SZ', '') RegWrite('HKCR\7-Zip.' & $Element & '\shell\open\command', '', 'REG_SZ', '"' & @ProgramFilesDir & '\7-Zip\7zFM.exe" "%1"') Next Link to comment Share on other sites More sharing options...
lafafmentvotre Posted February 2, 2011 Author Share Posted February 2, 2011 thank you for your answers Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now