1.

Solve : win 7 batch file has issues with spaces in network path name?

Answer»

I have a batch FILE that performs perfectly in win xp over the network and locally in win 7, but when running this batch file on network volumes that contain spaces FAILS.

The batch file is ran on a .swf file and will copy the swf file to the target of the shortcut.lnk files located in the parent directory that link to other FOLDERS on the same volume located higher in the directory tree

HERE is the folder structure
Quote

Volume in drive H is Data
Volume Serial Number is 064B-6BB0

Directory of H:\batch_testing\lesson

08/16/2011 05:01 PM <DIR> .
08/16/2011 05:01 PM <DIR> ..
08/16/2011 05:07 PM <DIR> FRAME
08/16/2011 04:56 PM 1,061 media.lnk
08/16/2011 04:56 PM 1,081 pictlib.lnk
2 File(s) 2,142 bytes

Directory of H:\batch_testing\lesson\frame

08/16/2011 05:07 PM <DIR> .
08/16/2011 05:07 PM <DIR> ..
08/16/2011 03:15 PM 1,043 win7_swf_uploader.bat
08/16/2011 09:25 AM 50,011 x756x-02-01_35514.swf
2 File(s) 51,054 bytes

Total Files Listed:
4 File(s) 53,196 bytes
5 Dir(s) 127,287,939,072 bytes free

this batch file WOULD be ran on the .swf file inside the "frame" folder and its contents are here
Code: [Select]::@echo off
%~d1
cd "%~p1"
set swf=%~f1

set media=%~p1..\media.lnk
echo set WshShell = WScript.CreateObject("WScript.Shell")>DecodeShortCut.vbs
echo set Lnk = WshShell.CreateShortcut(WScript.Arguments.Unnamed(0))>>DecodeShortCut.vbs
echo wscript.Echo Lnk.TargetPath>>DecodeShortCut.vbs
set vbscript=cscript //nologo DecodeShortCut.vbs
For /f "delims=" %%T in ( ' %vbscript% "%media%" ' ) do set Mtarget=%%T
del DecodeShortCut.vbs

set pictlib=%~p1..\pictlib.lnk
echo set WshShell = WScript.CreateObject("WScript.Shell")>DecodeShortCut.vbs
echo set Lnk = WshShell.CreateShortcut(WScript.Arguments.Unnamed(0))>>DecodeShortCut.vbs
echo wscript.Echo Lnk.TargetPath>>DecodeShortCut.vbs
set vbscript=cscript //nologo DecodeShortCut.vbs
For /f "delims=" %%T in ( ' %vbscript% "%pictlib%" ' ) do set Ptarget=%%T
del DecodeShortCut.vbs

echo media %media%
echo Media_Target %Mtarget%
echo.
echo pictlib %pictlib%
echo pictlib_target %Ptarget%

copy /Y "%swf%" "%Mtarget%"
copy /Y "%swf%" "%Ptarget%"

pause > nul


please help identify any issues in my coding and feel free to ask any other questions to help this get resolved.
TIA for your holp.


Discussion

No Comment Found