VMware Horizon Community
MrBeatnik
Hot Shot
Hot Shot

Post synchronization script (again?)

Hi,

Problems with the Post Synchronization Script on pools (automated desktops).

I've read a bit about this, but can't seem to find definitive answers anywhere.

I was curious if anyone can enlighten me (and probably others) with my quesitons (and possible example responses) below?

1) What can you run from the script, and why?

e.g. You can only run .BAT and .CMD because it's running at a theoretical mini-setup time rather than in "explorer.exe".

2) I have heard you have to "chain" scripts, true of false. Why?

e.g. If I want to run a VBS, I have to call a BAT file first, which then calls the VBS because...?

3) Can you run an EXE? If so - how, and if not, why not.

e.g. No you can't because it's running at a theoretical mini-setup.

4) Does the quick-prep user have admin privs or should I add them to the master machine (my user is NOT a domain admin).

I have an EXE which performs some actions on the machine. Running it when logged on to one of the machines allows it to work OK of course.

This EXE writes to a log. No log creation is good evidence to say it hasn't run.

I have tried:

Running a batch file as the post sync which calls the EXE directly.

Running a batch file which calls a VBS scrips which calls the EXE.

Running a VBS script which calls the EXE.

None of these options work!

Any answers to my questions (for clarification) and any suggestions on how to move forward with getting an EXE to run?

Thanks

Tags (1)
0 Kudos
13 Replies
Linjo
Leadership
Leadership

Maybe this blogpost will help: http://www.thatsmyview.net/2009/04/16/post-syncronization-scripts/

Best regards,

Linjo

If you find this information useful, please award points for "correct" or "helpful".

Best regards, Linjo Please follow me on twitter: @viewgeek If you find this information useful, please award points for "correct" or "helpful".
0 Kudos
ChrisKubiak
Enthusiast
Enthusiast

1. As far as I know only BAT files are executed (havnt had much luck with others).

2. I guess it depends on your needs and what you mean by chaining. I have one bat file that runs 2 different exes and runs regedit to silently import a regkey. I dont concider that chaining though, I would consider it chaining if it went App1 -> App2 -> Regedit.

3. Yes, you just need to have the command saved in a BAT file and then execute the BAT file.

4. From my testing its running as SYSTEM.

I have tried:

"Running a batch file as the post sync which calls the EXE directly"

Was the BAT file on the actual image itself and did you put the full path to the EXE in the BAT file (using quotes if needed)? One possible tip I can add is add START to the begining of your code, instead of "c:\software\myfile.exe" put "START c:\software\myfile exe".

Running a batch file which calls a VBS scrips which calls the EXE.

If you want to launch a VB script you need to do Cscript \nameofscript.vbs

Running a VBS script which calls the EXE.

I believe you can only execute a BAT file.

MrBeatnik
Hot Shot
Hot Shot

Hi Linjo,

I had come across that article before posting here - I even left a comment on that post with similar questions to here; it doesn't give the full information on the conditions/rules using the post-sync scripts. See my comments on that page for further info directly related to that post, but thanks for pointing it out - others may not know it is there.

0 Kudos
MrBeatnik
Hot Shot
Hot Shot

Hi Chris,

Thanks for the responses.

On point 2, yes chaining isn't perhaps the best term for me to use - however I have tried your chain scenario (app1 -> app2 > regedit) with no success.

On point 4, this is strange as it suggests in the View Admin docs that the AD registration user is also being used for quickprep (it also says this in the pool overview when it is created), but perhaps this relates to the issue :: perhaps it is using system when it should be using another user. I would like to confirm this for certain. Perhaps echoing the username variable from a QP script (if I can get it working) will confirm.

Was the BAT file on the actual image itself and did you put the full path to the EXE in the BAT file (using quotes if needed)? One possible tip I can add is add START to the begining of your code, instead of "c:\software\myfile.exe" put "START c:\software\myfile exe".

Hmmn, yes I had only tried CALL instead of START.

Are there any other tips (@echo off REQUIRED for example)?

Running a batch file which calls a VBS scrips which calls the EXE.

If you want to launch a VB script you need to do Cscript <path to script>\nameofscript.vbs

I don't NEED to run a vbs, I was just trying different ways to get something working... but true enough I didn't try the cscript (and that's silly as I read that elsewhere too).

I will give these options a try later tonight and see what I can come up with.

Does anyone know when exactly the script is run? Is explorer running (I presume so if you can run an EXE).

I'll post back with more results later.

Thanks.

0 Kudos
ChrisKubiak
Enthusiast
Enthusiast

I have a bat file called c:\software\RegisterUnmanaged.bat on my parent image, in the pool config under post synchronization script I put that path.

The contents of that BAT file:

Start
c:\software\logs\ImprivataRunOnce.txt

c:\software\whoami.exe

The 2 EXEs in this case are custom written compiled apps using WinBatch. The first one is used to take the unmanaged installation of our AV software and register it with the server (this is done so it can get a custom config). The second one was used in testing basically it logs the name of the currently logged in user (hence the belief that it’s the SYSTEM account that is performing the script). The Reg file just throws an entry into the Run Once key (I kept forgetting to put it back every time I was tweaking the master image).

I’m far from an expert on the topic but these are my experiences\observations. What is the EXE you are running or what does it do? Can you successfully run the EXE from a BAT file right from Windows (ie manually running it, not the P-S script function)?

MrBeatnik
Hot Shot
Hot Shot

I’m far from an expert on the topic but these are my experiences\observations.

Heh, I'm yet to see any posts where people have definitive answers. I'm unsure there are any experts on this particular area as yet, just a lot of feeling about - maybe I have missed some good posts out there.

What is the EXE you are running or what does it do? Can you successfully run the EXE from a BAT file right from Windows (ie manually running it, not the P-S script function)?

My EXE is a custom EXE as well. I can indeed successfully run it from regular use (included any "chained" method of calling as mentioned in previous posts).

The second one was used in testing basically it logs the name of the currently logged in user (hence the belief that it’s the SYSTEM account that is performing the script).

I think I was perhaps misunderstanding what "Domain and account for QuickPrep" meant - I was assuming that this not only applied for the AD registration, but also P-S script which happens during the "quickprep" period. Anyway, that's good to know.

One other thing that I have thought about with you mentioning the START use... the START /WAIT option.

If the EXE being called takes a little longer to complete, the /WAIT option may be required (if it works) to keep the P-S script user active (i.e. the machine doesn't reboot during the script because the called BAT file has already completed). I will test this as part of my process too.

At the moment haven't had time to test, but I will post back my results.

0 Kudos
MrBeatnik
Hot Shot
Hot Shot

HI again all.

Problems still exist.

So far I have attempted to call a batch file that does any of the following commands, with no success:

my.exe

call my.exe

start my.exe

start /wait my.exe

cscript qp.vbs

dir > c:\dir1.txt

None of these have been successful.

By the way, to test these options I created all of these batch files in the master image and then just changed the pool settings to point to the file I was testing, and refreshed..

Note I have tested all these batch files running as System (performed an "AT /interactive CMD" to get a system command prompt) and all work fine.

Is there any logging in regards to P-S script (i.e. event log has many View entries, but nothing for P-S script that I can see.

0 Kudos
ChrisKubiak
Enthusiast
Enthusiast

By saying "refreshed" Im assuming that means you are testing on a persistent pool. Have you tried these tests on a non-persistent pool or on a freshly built VM? (ie expanding the pool, creating a new pool)

0 Kudos
MrBeatnik
Hot Shot
Hot Shot

By saying "refreshed" Im assuming that means you are testing on a persistent pool. Have you tried these tests on a non-persistent pool or on a freshly built VM? (ie expanding the pool, creating a new pool)

Yes, testing on an Automated, Persistent pool using linked clone and composer, so When I say refresh, I am:

Edit Image... > Refresh (discard all changes and restore) > All machines.

In VC I can see the current machine being deleted, so I assumed (naively?) that when the new machine is created from the linked clone master, the (changed) pool P-S script setting I specified is being processed.

I have tried a couple on a "fresh" VM (same persistent pool, but new snapshot chosen) with no luck.

I will try creating a non-persistent pool.

I appreciate you given your time on this.

It seems this is a little bit of a dark art.

0 Kudos
ChrisKubiak
Enthusiast
Enthusiast

Well there's your problem right there! You failed to sacrifice a goat before making the pool. lol

0 Kudos
MrBeatnik
Hot Shot
Hot Shot

Hmmmn, the magic isn't working. At least not on Persistent pools!

Ok,

So I created a brand new pool but this time non-persistent.

The script ran! It worked. Note, that it did only run halfway through my EXE (the loggin stopped after about 15 seconds), which makes me consider that the START /WAIT command would be a requirement as it likely rebooted before completing.

But the EXE did run, and started logging as it should.

However, when I created a brand new PERSISTENT pool, based on the same snapshot and pool settings as the non-persistent working pool, it failed again. Actually I noticed another issue where I set the UDD as "same as OS disk", but it creates a UDD anyway - this may be part of the overall issue? I need to try and address that first maybe to ensure we don't have any real issues.

So we are getting some "rules" together for P-S script - I will try the start /wait on the non-persistent pool to see if that works, and maybe it doesn't work on persistent pools at all, but lets cure other errors first.

I'll keep this thread open for a bit and come back when I have even more results. In the mean time, more suggestions or people with similar problems posting would be helpful.

0 Kudos
MrBeatnik
Hot Shot
Hot Shot

Ok, just a quick bump.

The post synchronization script does not work for us at all for a persistent pool.

Non-persistent pool works just fine.

Does anyone else have a similar scenario?

We are running View 4, VC 4 w/Composer2, ESX 3.5

Does anyone have the scripts working with persistent pools running View 4?

May have to open a case with VMWare; this is quite an important feature for us.

0 Kudos
MrBeatnik
Hot Shot
Hot Shot

We have resolved the issue it seems (hope I'm not getting ahead of myself).

(THe issue of scripts not running on persistent pools, there are still some mysteries of the exact way a script works!!)

The problem was ESX 3.5.

Upgrading to vSphere U1 has resolved the issue - scripts are now running on persistent pools.

Very strange. I guess this was missed in QA when VMWare said 3.5 works with Vew 4.

We are happy now. I hope this post helps others who might have a similiar issue.

BTW - This also resolved an issue with UDD (another post).

0 Kudos