I made a batch file to copy fonts into windows fonts directory. It’s working on 32bit OS but windows 8.1 64bit. What’s the problem? @echo off set dest=%windir%\Fonts for %%K in (*.*) do if not exist "%dest%\%%~nxK" copy "%%K" "%dest%\%%~nxK"
Since the Windows directory is a protected area in that OS, you did 'Run as administrator', didn't you?
@Kamrul08 The problem when you run the script as admin is that the active directory gets changed to: "C:\Windows\system32" or generally to "%windir%\system32", so the 'FOR loop' is actually looking into "C:\Windows\system32" for files to copy, and you can see that if you 'ECHO' "%%K" in the loop or 'ECHO' "%CD%" outside the loop. Anyway i guess you're trying to copy fonts from the same dir as the script to "%windir%\fonts", am i right? if so simply change the active/working directory by adding this line at the beginning of the script or just before the loop: Code: cd /d "%~dp0" another solution, in case you don't want to change the active directory for the rest of the script, or you want to change it only until the 'FOR' loop is finished add this line just before the loop: Code: pushd "%~dp0" then this line just after the loop: Code: popd then you can run the script as admin safely.
Yes, I’m trying to copy from same directory of my batch file to Windows\Fonts directory. Code: pushd "%~dp0" I also used your pushd %~dp0 command. It shows files copied, but actually not. No copied files in the Windows\Fonts directory. The command is working with 32Bit or another directory in 64Bit.
If you're copying using the 'all files' wildcard from the same directory as the script then you will also be copying the script to the Fonts directory! Try this 'Run as administrator' instead! Code: @Echo Off SetLocal Set "dest=%SystemRoot%\Fonts" If "%~dp0" NEq "%CD%" (If "%~dp0" NEq "%CD%\" PushD %~dp0) RoboCopy "%CD%" "%dest%" *.fon *.otf *.pfm *.ttf /XC /XN /XO As you can see it selects only specific file types to copy, (please change those to suit your needs). Additional note: I'm not sure that copying files to that location actually installs them for use, so if that is your intent the you may need to completely change your script.
Thanks all. Is there any difference between 32Bit and 64Bit command line? Especially for copy command? I used two commands in a batch file (added bellow). Command 1 doesn't work in 64Bit but 2 works fine. Difference is \ only. 1. copy "%~dp0x86.exe" "%ProgramFiles%\VS Revo Group\Revo Uninstaller Pro" 2. copy "%~dp0x86.exe" "%ProgramFiles%\VS Revo Group\Revo Uninstaller Pro\"