REM
REM	Installation wrapper for WQM7 to change folder permissions
REM
ECHO OFF
REM
REM	Test for OS version to select ACL tool
REM

REM	Variable declaration
SET DESTDIR=c:\DEP\WQM7
SET INSTSRC=WQM7
SET ERRAPP=0

REM	Set variable PERCENT0
REM	FOR %0 FIX SEE kb 318689

echo %0 | %systemroot%\system32\find.exe """" > nul
if errorlevel 1 goto NOQUOTES
if errorlevel 0 goto HASQUOTE

:NOQUOTES
set PERCENT0=%0
goto CONTINUE

:HASQUOTE
SET fold=%0
SET PERCENT0=%fold:"=%

:CONTINUE

%PERCENT0%\..\%INSTSRC%\setup.exe
SET ERRAPP=%ERRORLEVEL%

REM	Test for Windows 7
VER | %windir%\system32\find.exe /i "Version 7"
IF %ERRORLEVEL%==0 GOTO WIN7

REM	Test for Vista or Windows 2008
VER | %windir%\system32\find.exe /i "Version 6"
IF %ERRORLEVEL%==0 GOTO VISTA
GOTO NOVISTA

:WIN7
:VISTA
REM	Use ICACLS.exe with Vista/Windows 7/Server 2008
REM	Check for existence of ICACLS in system32 folder, first if not there use root copy

IF EXIST %windir%\system32\icacls.exe (
		%windir%\system32\icacls.exe %DESTDIR% /grant Users:(OI)(CI)F
	) ELSE (
		%PERCENT0%\..\icacls.exe %DESTDIR% /grant Users:(OI)(CI)F
	)


:NOVISTA
REM	Use CACLS.exe with non-Vista or non-Windows 7 or non-Server 2008 desktop OS
REM	Check for existence of CACLS in system32 folder, first if not there use root copy

IF EXIST %windir%\system32\cacls.exe (
		%windir%\system32\cacls.exe %DESTDIR% /T /E /R Users
		%windir%\system32\cacls.exe %DESTDIR% /T /E /G Users:F
	) ELSE (
		%PERCENT0%\..\ccacls.exe %DESTDIR% /T /E /R Users
		%PERCENT0%\..\ccacls.exe %DESTDIR% /T /E /G Users:F
	)

EXIT %ERRAPP%

