extraction zip %1 in c:\windows\fonts doesn t work

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Acris
Posts: 5
Joined: 01 Jan 2009 11:44

extraction zip %1 in c:\windows\fonts doesn t work

#1 Post by Acris » 19 Jan 2009 09:59

Hi

my code doesn't work i dont know why
you drop and drag fonts archive zip into batch file

OS : Vista

@echo off
set zip=%programfiles%\7-zip\
set "Fonts=%systemroot%\Fonts"
set clefFont=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts
attrib -r -h -s "%Fonts%"

cls &echo.&echo ==^> %~dpnx1

"%zip%\7z.exe" e "%~dpnx1" -r *.ttf *.otf -o"%Fonts%" -xr-!__MACOSX >> "zipFiles.txt"
attrib +r +s "%Fonts%"

for /f "tokens=1* delims= " %%v in (' type "zipFiles.txt" ^|find /i ".ttf"') do (REG ADD "%clefFont%" /v "%%~nw (TrueType)" /d "%%~nxw")
for /f "tokens=1* delims= " %%w in (' type "zipFiles.txt" ^|find /i ".otf"') do (REG ADD "%clefFont%" /v "%%~nx (TrueType)" /d "%%~nxx")
pause


I have no error message
zipFiles.txt is empty
files are not extracted
the batch is frozen

but
but if I change the directory, my batch runs

why ?

thanks a lot for your help

Acris

DosItHelp
Expert
Posts: 239
Joined: 18 Feb 2006 19:54

#2 Post by DosItHelp » 19 Jan 2009 21:00

Acris,

Not sure, here is what you could try:
Since the line with 7z.exe contains a exclamation character, it wouldn't work if DELAYEDEXPANSION is enabled.
Try with "setlocal disabledelayedexpansion"
@echo off
setlocal disabledelayedexpansion
set zip=%programfiles%\7-zip\
set "Fonts=%systemroot%\Fonts"
set clefFont=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts
attrib -r -h -s "%Fonts%"

cls &echo.&echo ==^> %~dpnx1

"%zip%\7z.exe" e "%~dpnx1" -r *.ttf *.otf -o"%Fonts%" -xr-!__MACOSX >> "zipFiles.txt"
attrib +r +s "%Fonts%"

for /f "tokens=1* delims= " %%v in (' type "zipFiles.txt" ^|find /i ".ttf"') do (REG ADD "%clefFont%" /v "%%~nw (TrueType)" /d "%%~nxw")
for /f "tokens=1* delims= " %%w in (' type "zipFiles.txt" ^|find /i ".otf"') do (REG ADD "%clefFont%" /v "%%~nx (TrueType)" /d "%%~nxx")
pause

Good Luck!

Acris
Posts: 5
Joined: 01 Jan 2009 11:44

#3 Post by Acris » 20 Jan 2009 00:12

Hi DosItHelp

7z.exe contains a exclamation character

yes, exclamation character is a switch command line exclude of 7zip.

exemple :

Code: Select all

-x[<recurse_type>]<file_ref>

<recurse_type> ::= r[- | 0]
<file_ref> ::= @{listfile} | !{wildcard}
7z a -tzip archive.zip *.txt -x!temp.*

adds to the archive archive.zip all *.txt files, except temp.* files.



I added setlocal disabledelayedexpansion but it doesn't work.

Post Reply