Combined with batch processing, shortcuts can be used to create and modify shortcuts in batches. But in practice, a problem is encountered. That is, if there are paths with spaces in the /P parameter or /W parameter or /I parameter when creating or modifying shortcuts with shortcuts, the creation of the shortcut will fail. And if there are spaces in the path of the shortcut parameter, it itself requires that the path be enclosed in quotes, thus causing a conflict. How to solve this problem? For example, a shortcut with the target "D:\UGS\NX 6.0\MACH\auxiliary\cls2clf.bat", the parameter "D:\UGS\NX 6.0\", the working path "D:\UGS\NX 6.0\MACH\auxiliary\", and the icon "D:\UGS\NX 6.0\UGTO2D\ugto2d.ico,0" will fail when created with shortcuts.
The following is the batch file and the shortcut I packaged. Please test how to solve this problem. The BS in the following program is a character replacement tool to replace any specified characters.
[ Last edited by HUNRYBECKY on 2008-8-4 at 08:23 AM ]
The following is the batch file and the shortcut I packaged. Please test how to solve this problem. The BS in the following program is a character replacement tool to replace any specified characters.
@ECHO OFF
REM When the file path is changed, batch replace (repair) shortcuts. The variable LNKPATH is the path of the shortcut folder to be replaced; OLDPATH is the original file installation path; NEWPATH is the new moved path
REM Suppose that after installing CATIA, the file path is moved or a green CATIA is to be made, then the shortcut path should be changed accordingly
SET LNKPATH="%ALLUSERSPROFILE%\「开始」菜单\程序\【HYSOFT】\UGSNX6绿色精简版"
SET OLDPATH="D:\UGS
SET NEWPATH="D:\PROGRAMS PROFILES\UGS"
SET PATH=%CD%;%CD%\GTOOLS\;%PROGRAMFILES%\WINRAR;%PATH%
IF NOT EXIST ".\GTOOLS\BS.exe" SET ERR=The character replacement tool is missing in the installation support directory, and the installation program cannot continue&&GOTO:ERROR
IF NOT EXIST ".\GTOOLS\SC.exe" SET ERR=The shortcut creation tool is missing in the installation support directory, and the installation program cannot continue&&GOTO:ERROR
FOR /F "DELIMS=" %%I IN ('DIR /B/S "%LNKPATH%\*.LNK"') DO (
SC /F:"%%I" /A:Q>"%TEMP%\SCUT.TXT"
BS "%TEMP%\SCUT.TXT" %OLDPATH% %NEWPATH% /I>NUL&CLS
setlocal enabledelayedexpansion
FOR /F "TOKENS=1,* DELIMS==" %%A IN (%TEMP%\SCUT.TXT) DO CALL SET %%A=%%B
IF EXIST "!TargetPath!" SC.EXE /F:"%%I" /A:E /T:"!TargetPath!" /P:"!Arguments!" /W:"!WorkingDirectory!" /I:"!IconLocation!" /D:"鸿越软件"
endlocal
)
SET ERR=Replacement and repair completed, thank you for using the tool made by Hongyue Software&&GOTO:ERROR
:ERROR
>"%TEMP%\Temp.vbs" Echo intAnswer = MsgBox("%ERR%" , vbYes, "Hongyue Software kindly reminds you!")
cscript //nologo "%TEMP%\Temp.vbs"
EXIT
[ Last edited by HUNRYBECKY on 2008-8-4 at 08:23 AM ]
Attachments
