I'm getting strange error "Unterminated entity reference" in a hybrid batch & VBS, which popups the UAC "Run as Admin" Dialog using an adaptation of this code, and then proceeds with unzipping a file to a folder on the system drive. The hybrid is structured similar to suggested here, and changing it is undesirable.
Tried adding CDATA VBS blocks without success. Restructuring the batch to replace :GetAdminRights function with the same section inside it doesn't help. Any ideas, what's wrong here?
<!-- : Begin batch script
@echo off
setlocal EnableExtensions EnableDelayedExpansion
set vbs="%temp%\_.vbs" & set "dir=C:\Unzip"
set "file=%USERPROFILE%\Downloads\archive.zip\"
call :GetAdminRights
cscript //nologo "%~f0?.wsf" //job:UNZ "%dir%" "%file%"
exit /b
:GetAdminRights
REM --> Check for permissions
IF "%PROCESSOR_ARCHITECTURE%" EQU "amd64" (
>nul 2>&1 "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system"
) ELSE (>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system")
REM --> If error flag set, user don't have admin permissions
if '%errorlevel%' NEQ '0' (echo Requesting administrative privileges...
) else (set "adm=1")
if not defined adm (set params = %*:"=""
cscript //nologo "%~f0?.wsf" //job:ADM %~s0 !params!
) else (pushd "%CD%" & CD /D "%~dp0")
exit /b
----- Begin wsf script --->
<package>
<job id="ADM"><script language="VBScript">
<![CDATA[
Set UAC = CreateObject("Shell.Application")
UAC.ShellExecute "cmd.exe", "/c ""wscript.Arguments(0)"" wscript.Arguments(1)", "", "runas", 1
]]>
</script></job>
<job id="UNZ"><script language="VBScript">
<![CDATA[
set fso = CreateObject("Scripting.FileSystemObject")
If NOT fso.FolderExists(wscript.Arguments(0)) Then
fso.CreateFolder(wscript.Arguments(0))
End If
set objShell = CreateObject("Shell.Application")
set FilesInZip = objShell.NameSpace(wscript.Arguments(1)).items
objShell.NameSpace(wscript.Arguments(0)).CopyHere(FilesInZip)
set fso = Nothing
set objShell = Nothing
]]>
</script></job>
</package>
::Error
\test.bat?.wsf(44, 12) Windows Script Host: Unterminated entity reference - matching ';' not found