VMware Horizon Community
TomHowarth
Leadership
Leadership

cannot get a post sync script to run post linked clone provision.

I have been banging my head against this particular brick for nearly 4 days now,  We need to get the Liquidware Labs Stratusphere UX agent working in the deployed linked clones.

This is a synopsis of what as been done so far:

Snap shot taken of Gold image.

Connector ID agent installed to Image, and confirmed that the agent is talking to the hub.

VMwareView_MasterImagePrep.bat file run to remove the "crt" file from the agent directroy structure and stop and change the LWL Stratusphere services to manual.

This is the script that LWL provide:

@echo off

: disable auto start of Liquidware Labs services

cd /d %~dp0

set checkpoint="tntgrd"

sc config "tntgrd" start= demand

if %ERRORLEVEL% NEQ 0 (

   goto error

)

set checkpoint="tntuidsvc"

sc config "tntuidsvc" start= demand

if %ERRORLEVEL% NEQ 0 (

   goto error

)

set checkpoint="tntupdsvc"

sc config "tntupdsvc" start= demand

if %ERRORLEVEL% NEQ 0 (

   goto error

)

: clean driver

set checkpoint="idcontrol"

"%CD%\..\idcontrol.exe" clean

if %ERRORLEVEL% NEQ 0 (

   goto error

)

echo Done!

goto done

:error

   echo Error level: %ERRORLEVEL%. Failed to configure %checkpoint%.

   echo Make sure you run this batch file as administrator.

:done

   pause

   exit

The following files are placed in a newly created directory called scripts at the root of the C: drive.

VMWareView_PostSyncScript.bat

VMwareView_PostSync-Worker.bat.

The first file moves to the working folder and then calls the second batch.

@REM VMWareView Composer sometimes only runs the first line in the post sync script

@REM Use a worker batch file to work around this issue.

cd /d %~dp0

cmd.exe /c VMWareView_PostSyncScript-Worker.bat

This script has been modified to read as below to simplify the helper script:


cd /script

cmd.exe /c VMWareView_PostSyncScript-Worker.bat

The second batch file changes the services to auto and starts them.

@REM VMWare Views Composer sometimes only runs the first line in the post sync script.

@REM We work around this by using a proxy batch file that just calls this one

@echo Configuring CID Key services to start automatically...

@sc config "tntgrd" start= auto

@sc config "tntuidsvc" start= auto

@sc config "tntupdsvc" start= auto

@sc start tntgrd

@sc start tntuidsvc

@sc start tntupdsvc

@echo Completed!

@echo Please verify services are in Running state

There was no customization to this script.

IPconfig /release was then run to remove the IP Address from the Gold Master and a further snapshot was taken.  The pool is then edited to add a Post Sync file to enable the services post provisioning.

I have tried the following different methods to call the script

c:\scripts\VMWareView_PostSysncScript.bat

call /c c:\scripts\VMWareView_PostSysncScript.bat

start c:\scripts\VMWareView_PostSysncScript.bat

I have even attempted to use psexec

psexec -hsi cmd.exe /c c:\scripts\VMwareView_PostSyncScript.bat

However when rebalancing,  we always receive the following error:

View Composer agent initialization state error (19): Failed to execute postsync script (waited 0 seconds)

When checking the %system_drive%\Windows\Temp\vmware-viewcomposer-ga-new.log file, we see the following in there:

2016-01-22 15:53:52,245 [1420] INFO  Ready  -  [Ready.cpp, 128] Running the PostSync script: "start" C:\script\VMwareView_PostSyncScript.bat with timeout: 20000

2016-01-22 15:53:52,245 [1420] DEBUG Wow64FsRedirectionOff  - [Wow64FsRedirectionOff.cpp, 109] Successfully disabled WOW FS redirection.

2016-01-22 15:53:52,248 [1420] FATAL Guest  -  [Guest.cpp, 486] RunScript: Unable to execute script: 006FACB0 , error = 2

2016-01-22 15:53:52,680 [1420] DEBUG Wow64FsRedirectionOff  - [Wow64FsRedirectionOff.cpp, 135] Successfully reverted WOW FS redirection.

2016-01-22 15:53:52,828 [1420] FATAL Ready  -  [Ready.cpp, 141] Failed to run PostSyncScript: "start" C:\script\VMwareView_PostSyncScript.batUnable to create process for the scriptError 2 (0x2): The system cannot find the file specified.

Which seems to indicate that the file cannot be found, however when visually  checking the VM guest, we can plainly see the files in the correct location.

Manually running the files correctly run the scripts and adds the machine to the Stratusphere Hub inventory. so communications between the guest and the hub is not a factor.

Tom Howarth VCP / VCAP / vExpert
VMware Communities User Moderator
Blog: http://www.planetvm.net
Contributing author on VMware vSphere and Virtual Infrastructure Security: Securing ESX and the Virtual Environment
Contributing author on VCP VMware Certified Professional on VSphere 4 Study Guide: Exam VCP-410
0 Kudos
1 Reply
EricNichols
Hot Shot
Hot Shot

I played around with doing things like passing script parameters, joining a domain, and calling other scripts from the post recompose script and found that it was unreliable. Sometimes it would time out and sometimes it would fail silently and other times it would have trouble expanding environment variables.

One thing I learned is that the user the script runs as can be changed by changing the user the composer service runs as and that it is not a domain account. The default is "nt authority\system". Try changing the composer service account to the domain account used for your view service and see if that helps.

Our post recompose script calls a second minimized.

A long shot, but depending on how and where you got your .cmd\.bat files, they may have been marked with an alternate data stream as having come from an untrusted source. https://blogs.technet.microsoft.com/askcore/2013/03/24/alternate-data-streams-in-ntfs/

c:\windows\setup\scripts\VDI-Post-Syncronization1.cmd:

start c:\windows\setup\scripts\VDI-Post-Syncronization2.cmd %*

c:\windows\setup\scripts\VDI-Post-Syncronization2.cmd:

@ECHO on

ECHO Please do not touch this window.

set ScriptParameters=%*

set Parameter1=%1

set Parameter2=%2

set Parameter3=%3

REM remove the contents of any existing log and add a line to the top

ECHO Start of VDI-Post-Syncronization.cmd.log > %WINDIR%\temp\VDI-Post-Syncronization.cmd.log

ECHO %DATE% %TIME% >> %WINDIR%\temp\VDI-Post-Syncronization.cmd.log

echo. >> %WINDIR%\temp\VDI-Post-Syncronization.cmd.log

whoami >> %WINDIR%\temp\VDI-Post-Syncronization.cmd.log 2<&1

echo. >> %WINDIR%\temp\VDI-Post-Syncronization.cmd.log

echo Script Parameters, %ScriptParameters% >> %WINDIR%\temp\VDI-Post-Syncronization.cmd.log

echo. >> %WINDIR%\temp\VDI-Post-Syncronization.cmd.log

rem golden image was set to not update its AD password every 30 days, this reverts that back to default

reg add HKLM\SYSTEM\CurrentControlSet\services\Netlogon\Parameters /v DisablePasswordChange /t REG_DWORD /d 0 /f >> %WINDIR%\temp\VDI-Post-Syncronization.cmd.log 2<&1

NETSH winhttp SET proxy yourproxyserver:8080 >> %WINDIR%\temp\VDI-Post-Syncronization.cmd.log 2<&1

Here is the log output of ours running successful. Notice there is not an extra "start" as there is in your log.

2016-05-03 15:22:41,627 [2148] INFO  Ready  -  [Ready.cpp, 128] Running the PostSync script: "c:\windows\setup\scripts\VDI-Post-Syncronization1.cmd" with timeout: 20000

2016-05-03 15:22:41,627 [2148] DEBUG Wow64FsRedirectionOff  -  [Wow64FsRedirectionOff.cpp, 109] Successfully disabled WOW FS redirection.

2016-05-03 15:22:58,561 [2148] INFO  Guest  -  [Guest.cpp, 532] Script "c:\windows\setup\scripts\VDI-Post-Syncronization1.cmd" standard ouput:

C:\Windows\system32>start c:\windows\setup\scripts\VDI-Post-Syncronization2.cmd 

2016-05-03 15:22:58,561 [2148] DEBUG Wow64FsRedirectionOff  -  [Wow64FsRedirectionOff.cpp, 135] Successfully reverted WOW FS redirection.

In the pool, it should look like this:

Untitled.png

0 Kudos