Why doesn't it work: Unzip to the Fonts folder?

Microsoft Windows
Post Reply
User avatar
MigrationUser
Posts: 336
Joined: 2021-Jul-12, 1:37 pm
Contact:

Why doesn't it work: Unzip to the Fonts folder?

Post by MigrationUser »

19 Jan 2009 13:59
Acris

Hello guy

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

OS : vista

Code: Select all

@echo off
set zip=%programfiles%\7-zip\
set Fonts=%systemroot%\Fonts 
attrib -r -h -s  "%Fonts%"

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

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

zipfile.txt
7-Zip 4.64 Copyright (c) 1999-2009 Igor Pavlov 2009-01-03

Processing archive: C:\Users\Acris\Desktop\star_jedi.zip

can not open output file C:\Windows\Fonts \STJEDISE.TTF
can not open output file C:\Windows\Fonts \Stjldbl1.ttf
can not open output file C:\Windows\Fonts \Stjldbl2.ttf
can not open output file C:\Windows\Fonts \Strjmono.ttf
can not open output file C:\Windows\Fonts \Starjedi.ttf
can not open output file C:\Windows\Fonts \Starjhol.ttf
can not open output file C:\Windows\Fonts \Starjout.ttf
Sub items Errors: 7
I can not extract my archive in the fonts I do not see why it does not work
could you help me explain?

Last edited by Acris (19 Jan 2009 14:01)

----------------------------

#2 19 Jan 2009 14:21
bluesxman


You seem to have a space at the end of this line:

Code: Select all

set Fonts=%systemroot%\Fonts
The safest way to "set" variables is to quote wrap them, like so:

Code: Select all

set "Fonts=%systemroot%\Fonts"
Last edited by bluesxman (19 Jan 2009 14:22)

cmd | *sh | ruby | chef

----------------------------

#3 19 Jan 2009 14:34
Acris


I have changed my code this set but it does not work
i have no space at the end of the line :

set Fonts=%systemroot%\Fonts

Code: Select all

    @echo off
    set zip=%programfiles%\7-zip\
    set "Fonts=%systemroot%\Fonts"
    attrib -r -h -s  "%Fonts%"

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

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

#4 19 Jan 2009 14:46
bluesxman


Trust me, on the text you pasted earlier there is a space on the "set Fonts=" line. But anyway, what errors do you receive?

cmd | *sh | ruby | chef

----------------------------

#5 19 Jan 2009 14:54
Acris


zipfile.txt is empty and
files are not extracted by 7zip

try this : http://www.box.net/shared/jyjkptde01

----------------------------

#6 19 Jan 2009 15:07
bluesxman


But what error messages does the failed extraction produce?

What happens when you run that same sequence of commands by hand, rather than using a script?

Have you tried extracting to somewhere else, other than c:\windows\fonts?

cmd | *sh | ruby | chef

----------------------------

#7 19 Jan 2009 15:15
Acris


I have no error message
files are not extracted
the batch is frozen
What happens when you run that same sequence of commands by hand, rather than using a script?
the files are extracted
Have you tried extracting to somewhere else, other than c:\windows\fonts?
Yes, I tried extraction in another folder other thanc:\windows\fonts and it works

this code works perfectly

Code: Select all

    @echo off
    set zip=%programfiles%\7-zip\

    set WinFonts=%Systemroot%\Fonts
    SET TmpFonts=%SystemDrive%\applications

    if exist "%zip%" "%zip%\7z.exe" e "%~dpnx1" -r *.ttf *.otf -o"%TmpFonts%"  -xr-!__MACOSX >> "zipFiles.txt"
    attrib -r -h -s  "%WinFonts%"
    copy "%TmpFonts%\*.*" "%WinFonts%"
    attrib +r  +s  "%WinFonts%"
    pause
but I'd like to be extracted directly from the directory c:\windows\Fonts

the code works too
without >> zipfile.txt

Code: Select all

@echo off
set zip=%programfiles%\7-zip\
set "Fonts=%systemroot%\Fonts"
attrib -r -h -s  "%Fonts%"

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

"%zip%\7z.exe" e "%~dpnx1" -r *.ttf *.otf -o"%Fonts%" -xr-!__MACOSX
attrib +r  +s  "%Fonts%"
pause
but I have need to store the result of the extraction in a txt file to create the keys in the Registry

Code: Select all

set clefFont=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\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")
Last edited by Acris (19 Jan 2009 15:21)

----------------------------

#8 19 Jan 2009 15:24
bluesxman


OK.

If you don't send the output to "zipFiles.txt" (for the purposes of troubleshooting only), what happens?

cmd | *sh | ruby | chef

----------------------------

#9 19 Jan 2009 15:29
Acris


my batch works

Code: Select all

    @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
    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
but I have need to store the result of the extraction in a txt file to create the keys in the Registry

----------------------------

#10 19 Jan 2009 15:32
bluesxman


Strange. What happens if you fully path the output file? Something like this:

Code: Select all

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

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

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

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

----------------------------

#11 19 Jan 2009 15:35
Acris


i know it's very stange
i have try your code but it doesnt work too.
I have no error message
files are not extracted
the batch is frozen

Last edited by Acris (19 Jan 2009 15:36)

----------------------------

#12 19 Jan 2009 16:24
bluesxman


And nothing in the text file? It smells like it's prompting you for some reason, but the redirect is hiding the prompt.

In lieu of any useful information in the zipFiles.txt file, I suggest you just use this version:

Code: Select all

@echo off
set zip=%programfiles%\7-zip\

set WinFonts=%Systemroot%\Fonts
SET TmpFonts=%SystemDrive%\applications

if exist "%zip%" "%zip%\7z.exe" e "%~dpnx1" -r *.ttf *.otf -o"%TmpFonts%"  -xr-!__MACOSX >> "zipFiles.txt"
attrib -r -h -s  "%WinFonts%"
copy "%TmpFonts%\*.*" "%WinFonts%"
attrib +r  +s  "%WinFonts%"
pause
... seeing as you say it works. It might not be ideal, but sometimes it's just easier to use a workaround than to spend hours trying to figure out why the "correct" method doesn't work.

Last edited by bluesxman (19 Jan 2009 16:26)

cmd | *sh | ruby | chef

----------------------------

#13 19 Jan 2009 16:35
Acris


this code works but it is not possibleto create the keys in the Registry


under vista fonts that are seen it is critical to create the registry keys

thanks for your help.
Good afternoon.

----------------------------

#14 19 Jan 2009 19:17
Simon Sheppard


The script centre has what looks like an easier way:
How Can I Install Fonts Using a Script?
https://web.archive.org/web/20090720005 ... y0425.mspx

Code: Select all

Const FONTS = &H14&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(FONTS)
objFolder.CopyHere "C:\Scripts\Myfont.ttf"
----------------------------

#15 21 Jan 2009 18:10
avery_larry


Still a problem?

Try to echo this line:

Code: Select all

echo "%zip%\7z.exe" e "%~dpnx1" -r *.ttf *.otf -o"%Fonts%" -xr-!__MACOSX
and then type the line that's echo'ed directly at the command prompt and see what happens.

----------------------------

#16 22 Jan 2009 11:39
Acris


Hi avery_Larry

Code: Select all

echo "%zip%\7z.exe" e "%~dpnx1" -r *.ttf *.otf -o"%Fonts%" -xr-!__MACOSX
result :
c:\program files\7-zip\ e "star.zip" -r *.ttf *.otf -o"C:\Windows\Fonts" -xr-!__MACOSX

without >> "zipFiles.txt"
my code works
the problem is >> "zipFiles.txt" it doesn't work

Code: Select all

c:\program files\7-zip\ e "star.zip"  -r *.ttf *.otf -o"C:\Windows\Fonts" -xr-!__MACOSX >> "zipfiles.txt"
zipfiles is empty. console windows freeze

----------------------------

#17 22 Jan 2009 13:45
bluesxman


Can you REM out the @echo off line and copy+paste in exactly what you see in the console? Remove anything potentially sensitive, if necessary.

cmd | *sh | ruby | chef

----------------------------

#18 26 Jan 2009 18:24
avery_larry


Hmmm . . . Maybe get rid of the spaces around the >> and see what happens? And maybe add a space after -o? (I've never used 7z.exe so I don't know if that's OK.)

Also you have and extra backslash because you define %zip% with a trailing backslash and then use "%zip%\7z.exe" -- though I don't know if either of these things might be the problem.

Code: Select all

"%zip%7z.exe" e "%~dpnx1" -r *.ttf *.otf -o "%Fonts%" -xr-!__MACOSX>>"zipfiles.txt"
Last edited by avery_larry (26 Jan 2009 18:25)

----------------------------

#19 27 Jan 2009 11:03
Acris


avery_larry >> No, if i add a space after -o the command is wrong. Syntax is correct in my code
i think it is a problem : rights of the fonts Folder.
Post Reply