Expanding a Pre-made Profiles to a Desktop(s)
Post date: Oct 15, 2015 12:46:22 PM
You'll need the fallowing tools:
Tools
fciv
imagex
Both can be found here.
Whats does this script do ?
tests weather or not the user for which we want to create the profile is logged in and if so exit
Only run if it has run and completed all tasks successfully
Only run / repeat only the tasks that appear to not be completed right
HASH check everything !!
Copy "larger" files to the local computer, But NEVER the hash files !!
My Working Script
Profile-Aspire.bat
@echo off
:::: Test if profile is active / logged in
quser | find "aspire"
IF %ERRORLEVEL% == 0 GOTO :EOF
SET SERVERPATH=\\files\scripts\wpm
SET LOCALPATH=C:\windows\scripts
IF EXIST %SERVERPATH%\CreateLocalStorageBase.bat call %SERVERPATH%\CreateLocalStorageBase.bat
SET SCRIPTNAME=create_aspire_profile.v2
SET HASHTOOL=C:\windows\scripts\admins\fciv.exe
SET EXPANDIMAGE=0
IF NOT EXIST %LOCALPATH%\admins mkdir %LOCALPATH%\admins
IF NOT EXIST %LOCALPATH%\logs mkdir %LOCALPATH%\logs
IF EXIST %LOCALPATH%\logs\.%SCRIPTNAME% GOTO :EOF
echo Creating Aspire Testing Profile
echo ^ =^> Hash Tool Check
IF NOT EXIST %HASHTOOL% GOTO :CPHASHTOOL
IF EXIST %HASHTOOL% %SERVERPATH%\Tools\fciv.exe -v -XML %SERVERPATH%\Tools\fciv.exe.hash >NUL
IF %ERRORLEVEL% EQU 0 GOTO :HASHTOOL
:CPHASHTOOL
echo ^ =^> Hash Tool Loading
xcopy /Y /V /Z %SERVERPATH%\Tools\fciv.exe %LOCALPATH%\admins
IF %ERRORLEVEL% NEQ 0 GOTO :EOF
echo ^ =^> Hash Tool Loaded
:HASHTOOL
::: Check if profile exists and the hashs check out, if not recopy it
SET FILES=%SERVERPATH%\Profiles\Profile-aspire.wim
SET FILEL=%LOCALPATH%\admins\Profile-aspire.wim
IF NOT EXIST "%FILEL%" GOTO :YESCPProfile
IF EXIST "%FILEL%" %HASHTOOL% -v -XML "%FILES%.hash" >NUL
IF %ERRORLEVEL% EQU 0 GOTO :NOCPProfile
:YESCPProfile
echo ^ =^> Copying Profile image to local machine
xcopy /Y /V /Z "%FILES%" %LOCALPATH%\admins
IF %ERRORLEVEL% NEQ 0 GOTO :EOF
:NOCPProfile
SET FILES=%SERVERPATH%\Tools\Waik_3\amd64\imagex.exe
SET FILEL=%LOCALPATH%\admins\imagex.exe
IF NOT EXIST "%FILEL%" GOTO :YESCPimagex
IF EXIST "%FILEL%" %HASHTOOL% -v -XML "%FILES%.hash" >NUL
IF %ERRORLEVEL% EQU 0 GOTO :NOCPimagex
:YESCPimagex
echo ^ =^> Copying Profile image tool to local machine
xcopy /Y /V /Z "%FILES%" C:\windows\scripts\admins
IF %ERRORLEVEL% NEQ 0 GOTO :EOF
:NOCPimagex
echo ^ =^> Checking for existing profile
IF NOT EXIST c:\Users\aspire GOTO :NOLPROFILE
echo ^ =^> Hash Check Existing Profile
%HASHTOOL% -v -XML %SERVERPATH%\Profiles\Profile-aspire.hash >NULL
IF %ERRORLEVEL% EQU 0 GOTO :YESLPROFILE
echo ^ =^> Deleting Old Profile
IF EXIST c:\Users\aspire RD /S /Q c:\Users\aspire
IF EXIST c:\Users\aspire RD /S /Q c:\Users\aspire
:NOLPROFILE
echo ^ =^> Creating local DIR if needed
IF NOT EXIST c:\Users\aspire mkdir c:\Users\aspire
IF NOT EXIST c:\Users\aspire mkdir GOTO :EOF
echo ^ =^> Uncompressing image
SET EXPANDIMAGE=1
%LOCALPATH%\admins\imagex.exe /APPLY %LOCALPATH%\admins\Profile-aspire.wim 1 c:\Users\aspire
IF %ERRORLEVEL% NEQ 0 GOTO :EOF
:YESLPROFILE
echo ^ =^> Settings up REG Profilelist keys
regedit /S %SERVERPATH%\Profiles\Profile-aspire.reg
IF %ERRORLEVEL% NEQ 0 GOTO :EOF
IF %EXPANDIMAGE% EQU 0 GOTO :NOREHASH
echo ^ =^> Hash Check Expanded Profile
%HASHTOOL% -v -XML %SERVERPATH%\Profiles\Profile-aspire.hash >NULL
IF %ERRORLEVEL% NEQ 0 GOTO :EOF
:NOREHASH
echo ^ =^> Done
date /T > %LOCALPATH%\logs\.%SCRIPTNAME%
date /T > \\files\techinfo\wpm\%COMPUTERNAME%.%SCRIPTNAME%
:EOF
Things you'll need to change
My UNC paths to where I store my tools,reg files and profile
\\files\scripts\wpm\
The account in question in this scripts case
aspire
Things you'll need to do
Create your own Profile (See my how to here)
Create hashes of all the needed files,dir and tools
Examples
Hash file for imagex.exe (You don't have to store the whole path in the XML file nor do you have to store BOTH hash types. But I do.)
fciv.exe -add C:\windows\scripts\admins\imagex.exe -both -xml \\files\scripts\wpm\Tools\Waik_3\amd64\imagex.exe.hash
Hash for the WHOLE profile aspire
fciv.exe -add C:\users\aspire -r -both -xml \\files\scripts\wpm\Profiles\Profile-aspire.hash