@echo off
chcp 1251

setlocal enabledelayedexpansion

:CREATE_LINK
set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs"
echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT%

if "%PROCESSOR_ARCHITECTURE%" == "x86" (
    set TARGET_PATH="%ProgramFiles%\Avest\AvPCM_nces\get_crl.bat"
) else (
    set TARGET_PATH="%ProgramFiles(x86)%\Avest\AvPCM_nces\get_crl.bat"
)

if not exist !TARGET_PATH! (
    echo No suitable TargetPath found.
    goto :END
)

if exist "%USERPROFILE%\Desktop" (
    echo sLinkFile = "%USERPROFILE%\Desktop\Скачать СОС ГосСУОК.lnk" >> %SCRIPT%
) else (
    if exist "%USERPROFILE%\Рабочий стол" (
        echo sLinkFile = "%USERPROFILE%\Рабочий стол\Скачать СОС ГосСУОК.lnk" >> %SCRIPT%
    ) else (
        echo No suitable TargetPath for creating shortcut found.
        goto :END
    )
)

echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT%
echo oLink.TargetPath = !TARGET_PATH! >> %SCRIPT%
echo oLink.Save >> %SCRIPT%
cscript /nologo %SCRIPT%
del %SCRIPT%

:end
