Getting Python to run inside WinPE for glazier

1,865 views
Skip to first unread message

Echowinter

unread,
Feb 6, 2017, 9:56:56 AM2/6/17
to glazier...@googlegroups.com
Hi

I would like to test out glazier but have been unable to get it running inside WinPE. I can't get Python 2.7 to work within WinPE (Windows 10 version) due to side-by-side errors (missing C++ shared libs?) and I've tried running sxstrace and copying over various dll files - no success. Python 3.6.0 does work inside WinPE but running glazier gives endless "glazier module not found" errors, does anyone know if glazier is only designed for Python 2.7?

I've searched and read various posts on glazier to try and find a solution to this problem and have not seen one that reports success thus far. Has anyone been able to integrate Python into WinPE and have glazier actually run? If so, could you provide exact version numbers of each?


Matt LaPlante

unread,
Feb 6, 2017, 11:57:27 AM2/6/17
to Echowinter, glazier...@googlegroups.com
On Mon, Feb 6, 2017 at 8:56 AM, 'Echowinter' via glazier-discuss <glazier...@googlegroups.com> wrote:
Hi

I would like to test out glazier but have been unable to get it running inside WinPE. I can't get Python 2.7 to work within WinPE (Windows 10 version) due to side-by-side errors (missing C++ shared libs?) and I've tried running sxstrace and copying over various dll files - no success. Python 3.6.0 does work inside WinPE but running glazier gives endless "glazier module not found" errors, does anyone know if glazier is only designed for Python 2.7?

The published version is Python2.7, yes. Can you give the specific error message?

Echowinter

unread,
Feb 6, 2017, 12:08:01 PM2/6/17
to Matt LaPlante, glazier...@googlegroups.com
Matt,

Thanks for your response. Here is the error text: "The application has failed to start because it's side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for mroe detail."

I've also attached a screenshot of the WinPE error. I've used the stock winpe.wim I got from Windows 10 ADK and Python 2.7 from the Python.org website, installed to C:\Python27 to my Windows 7 machine (as there is no embedded zip version provided by the site for 2.7) and then copied across to WinPE
winpe-error.png

smith...@gmail.com

unread,
Feb 6, 2017, 8:32:11 PM2/6/17
to glazier-discuss
When I was investigating how to get python into a WinPE I read something about needing to also add some addition C++ libraries - I think this was it: https://msdn.microsoft.com/en-us/library/ms235316(v=vs.140).aspx

Matt LaPlante

unread,
Feb 6, 2017, 8:36:02 PM2/6/17
to Echowinter, glazier...@googlegroups.com
This means the PE is lacking a vc redistributable that the Python interpreter or libraries were built against. You can fix this by putting the dll and manifest from the redistributable package in with Python.

I don't know off hand exactly which version to recommend to you, but if you don't know which redist you need, sxstrace can usually tell you (mentioned in the error).

1. > sxstrace trace -logfile:trace.etl
2. run python.exe and produce the error
3. stop the sxstrace process
4. > sxstrace parse -logfile:trace.etl -outfile:trace.txt
5. open trace.txt

The trace should tell you what version the binary is looking for. Something like this:

INFO: Parsing Manifest File C:\python\python27.dll.
INFO: Manifest Definition Identity is (null).
INFO: Reference: Microsoft.VC90.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8"

Get the free redist download from Microsoft, and put the matching .dll and .manifest in with Python.


On Mon, Feb 6, 2017 at 11:07 AM, Echowinter <echow...@protonmail.com> wrote:
Matt,

Thanks for your response. Here is the error text: "The application has failed to start because it's side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for mroe detail."

I've also attached a screenshot of the WinPE error. I've used the stock winpe.wim I got from Windows 10 ADK and Python 2.7 from the Python.org website, installed to C:\Python27 to my Windows 7 machine (as there is no embedded zip version provided by the site for 2.7) and then copied across to WinPE
-------- Original Message --------
Subject: Re: Getting Python to run inside WinPE for glazier
Local Time: February 6, 2017 4:57 PM
UTC Time: February 6, 2017 4:57 PM
To: Echowinter <echow...@protonmail.com>

Echowinter

unread,
Feb 7, 2017, 5:39:43 AM2/7/17
to Matt LaPlante, glazier...@googlegroups.com
Matt,

Thanks but as I mentioned in my first post - I have already tried this with no success. I've been unable to locate the correct DLL(s) by the obscure references in the sxstrace log file. It would be helpful if someone could provide further information. I can't imagine the steps are different if we're all downloading Microsoft and Python binaries with known versions and expecting them to work together?

What version of WinPE are you using? (8.1? 10?)

What architecture of WinPE are you using (x86 or amd64?)? What architecture Python 2.7 are you using? I have read that WinPE 64-bit cannot run any 32-bit applications. I've focused my efforts on running WinPE 10 amd64 using Python 2.7 x86_x64

Where have you put the shared C++ libraries to obtain success? I found a "x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91" folder on my Windows 7 machine and copied the 3 DLL files (msvcm90.dll, msvcp90.dll msvcr90.dll) and "x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91.manifest" into the Python27 directory in WinPE - didn't work. I'm aware this references "x86" - but my 64-bit system has no "amd64" version

I've attached the sxstrace log and directory layout of Python27. As you can see I've even resorted to a scattershot approach of placing the binaries EVERYWHERE in the hope they get picked up
sxstrace_log.txt
python27_dir_layout.txt

Matt LaPlante

unread,
Feb 7, 2017, 5:49:43 PM2/7/17
to Echowinter, glazier...@googlegroups.com
If you use amd64 WinPE you'll want your Python and any other DLLs to all match. The 64 bit WinPE can't run the 32 bit binaries the way a full Windows install can. If you got the DLLs from x86_*, they probably won't work. You can confirm by looking in the manifest and seeing what the processorArchitecture=. 

I believe only msvcr90 is necessary, but I'm not 100% positive, and that could vary depending on the Python build and which modules are included.

You can get the 64 bit vcredist from Microsoft which should include the right DLLs: https://www.microsoft.com/en-us/download/details.aspx?id=2092



On Tue, Feb 7, 2017 at 4:39 AM, Echowinter <echow...@protonmail.com> wrote:
Matt,

Echowinter

unread,
Feb 8, 2017, 5:27:45 AM2/8/17
to Matt LaPlante, glazier...@googlegroups.com
I don't generally like to admit defeat on these issues but I think I've spent enough time on this, at least for now. I installed exactly what you suggested - but I've been unable to find the new files dropped by the installer. There is certainly no new "amd64_..." folder of the above naming convention and the sxstrace log suggests WinPE wants that version but amd64. I'm not saying "I'm going back to MDT! This is rubbish!" - I'll likely go back to running my bat scripts inside WinPE which produce similar effect but don't give me a headache trying to get working. I'll check back periodically to see if anyone, other than yourself, has been able to get WinPE working with Python 2.7. I will obviously not be the only one to run into the issue (which is quite a barrier to entry), since anyone who uses Microsoft's provided version of WinPE will not have these libraries pre-installed. I think I've provided enough information that this problem could be easily reproduced (stock WinPE + stock Python 2.7 = does not work) and perhaps solved by someone more experienced in these matters than I

Thanks again for all the help you were able to provide Matt

Matt LaPlante

unread,
Feb 15, 2017, 6:55:37 PM2/15/17
to Echowinter, glazier...@googlegroups.com
I appreciate your bringing the issue up as it gave us a reason to consider it. It's honestly one of those corners of the process where you do it once and rarely ever have to think about it again, so it's not something we've looked at much recently, and it's good to have a reminder of where the problem spots are. It should be relatively straight forward to migrate our code to Python 3, but I'm not sure I can say the same thing about every dependency, so that's something that remains to be seen.

Incidentally, it's usually possible to extract files from an installer like the redists without installing them. In some cases you'll get a command line flag that will do an extract rather than install. Some archivers like 7-zip can also open a lot of Windows installers directly, and just treat them like zip files. Comes in handy occasionally.



--
You received this message because you are subscribed to the Google Groups "glazier-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to glazier-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to glazier-discuss@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/glazier-discuss/oMe1LZCb3FFn7pxI7U7LlQaWQhamPi3moqp4SCRmBSZfbYOm7yuNimbCrSKkcfRZ0k4U7cPUDzjxXmVt58w2fisQuBb8EVXlJQdHzNuc2Wk%3D%40protonmail.com.

For more options, visit https://groups.google.com/d/optout.

Echowinter

unread,
Feb 17, 2017, 6:33:29 AM2/17/17
to Matt LaPlante, glazier...@googlegroups.com
Matt,

I've got Python 2.7 and Glazier working inside WinPE 10, it was the missing C++ redistributable

I have had to make a few modifications to get Glazier to work properly for me. I encountered some big problems with flags. I had to add the sys.argv snippet that djjohn provided in another topic here to get glazier to read any arguments. I had to move the defining of the perserve_tasks flag into constants.py to get it recognized, and the spec.py flags don't work at all (throws "UnknownSpec: None"). I've hard coded my os spec (comp_os = "windows7") to get things working which is good enough for my design

There is no shutdown.exe in system32 of WinPE 10 - again more patching - to power.py. Strangely, I found that a HTTP config_server wouldn't work for me - but HTTPS does. And lastly, I haven't yet managed to integrate the dependencies (pythoncom, pywintypes, and win32com) of the gwinpy dependency to get any meaningful hardware info. I expected to run into issues getting chooser UI to work but to my surprise it's working great and I'm using a lot of on/off user pins to include specific yaml files

Thanks Matt & team, it looks like Glazier will be useful. I hope you continue to push out updates (more actions!)

ca...@dantech.nz

unread,
Feb 19, 2017, 4:07:01 PM2/19/17
to glazier-discuss, ma...@google.com, echow...@protonmail.com
Thanks Matt,

I have also been able to get Python2.7 and Glazier working in WinPE 10. For those looking for help doing this the instructions above from Matt are good, you really just need the correct VC Redist - http://www.microsoft.com/downloads/details.aspx?familyid=bd2a6171-e2d6-4230-b809-9a8d7548c1b6&displaylang=en 

My observations/changes have been the same as Echowinter above:
- HTTP will not work, you must use HTTPS, and use certutil to import your cert.
- Add "flags.FLAGS(sys.argv)" to autobuild.py (as suggested by djjohn)
- Adjust lib/power.py to use 'wpeutil shutdown/reboot' as system32/shutdown.exe is not part of WinPE 10

Some variations:
- To avoid "UnknownSpec: None", I added '--glazer_spec=flag' to the command line rather than editing lib/spec/spec.py or flag.py
- I need to move defining of 'preserve_tasks' from autobuild.py to lib/constants.py to make it work after reboot out of WinPE (not sure if I did something wrong here). 

I have builds running successfully: starting WinPE, applying install.wim, installing drivers/updates, copying over Python/Glazier to boot drive, exiting WinPE, starting up new install (using unattend.txt) and installing some more drivers and applications (using chocolatey), then tidying up. 

(Also completely missed that there was a Chooser UI, looking in to this now.)

Still need to do some work to get WMI/build info working in WinPE 10. Matt if there are any pointers to getting this working, or Echowinter let me know if you have an success with this?

We'll be using this to replace our current build system in the near future I think. Thanks Matt.


C


On Mon, Feb 6, 2017 at 8:56 AM, 'Echowinter' via glazier-discuss <glazier...@googlegroups.com> wrote:
Hi

I would like to test out glazier but have been unable to get it running inside WinPE. I can't get Python 2.7 to work within WinPE (Windows 10 version) due to side-by-side errors (missing C++ shared libs?) and I've tried running sxstrace and copying over various dll files - no success. Python 3.6.0 does work inside WinPE but running glazier gives endless "glazier module not found" errors, does anyone know if glazier is only designed for Python 2.7?

The published version is Python2.7, yes. Can you give the specific error message?


--
You received this message because you are subscribed to the Google Groups "glazier-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to glazier-discu...@googlegroups.com.
To post to this group, send email to glazier...@googlegroups.com.

ca...@dantech.nz

unread,
Feb 19, 2017, 4:43:50 PM2/19/17
to glazier-discuss, ma...@google.com, echow...@protonmail.com, ca...@dantech.nz
Echowinter,


Seems to work now.


C

Echowinter

unread,
Feb 21, 2017, 11:59:49 AM2/21/17
to ca...@dantech.nz, glazier-discuss, ma...@google.com
Caleb,

Nice to hear from another user! It looks like we experienced and solved much of the same issues. I don't think the preserve_tasks issue was a variation between us - I had to do that too, it didn't even work in WinPE for me

You should definitely take a look at the chooser UI, it's great. I've focused on making my setup "zero touch" except for the selections made on the chooser UI in the WinPE stage

And thanks for the WMI stuff - I'll take a further look into that

fuzzy...@gmail.com

unread,
Aug 6, 2017, 10:40:15 AM8/6/17
to glazier-discuss, ca...@dantech.nz, ma...@google.com, echow...@protonmail.com
Hi,

  I managed to make it work like this in WinPE:

- install Python 2.7 on the host

- install the 64 bit vcredist on your host: https://www.microsoft.com/en-us/download/details.aspx?id=2092

edit c:\Python27\Microsoft.VC90.CRT.manifest and replace "9.0.30729.1" with "9.0.21022.8"
- type these 2 commands
copy c:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_08e61857a83bc251\* c:\Python27\DLLs

copy c:\Python27\Microsoft.VC90.CRT.manifest c:\Python27\DLLs

- now copy c:\Python27 to your Image


  Then as written above,

- HTTP will not work, you must use HTTPS, and use certutil to import your cert.

- Add "flags.FLAGS(sys.argv)" to autobuild.py (as suggested by djjohn)

- Adjust lib/power.py to use 'wpeutil shutdown/reboot' as system32/shutdown.exe is not part of WinPE 10


Regards,

oscar.lope...@gmail.com

unread,
Jul 27, 2018, 10:23:39 AM7/27/18
to glazier-discuss
Hi,

Thank you all for sharing the changes required to make this work. You have saved me a lot of time.

I have been able to set up glazier in my environment but am having issues with understanding how to call the post imaging actions.

The ExitWinPE action documentation states the following:

Performs multiple steps in one:

  • Copies the autobuild executable to C:
  • Copies the acting task list to C:
  • Reboots the host
However in my case it is only copying the acting task list and rebooting the host. I don't see any "autobuild executable" being copied. Am I missing something to make this work?

I see a reference to a "autobuild.bat" on the following section of the documentation: 

%WinDir%\System32\reg.exe add "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v Shell /t REG_SZ /d "cmd.exe /c start /MAX C:\Glazier\autobuild.bat"
%WinDir%\System32\shutdown.exe /r /t 10 /c "Rebooting to resume host configuration."

Is that a script that I need to write myself that calls autobuild.py ? Does that mean I need to copy Python/Glazier code to the C: drive before exiting WinPE?
If so, how does it know it needs to pickup the leftover activities?

Please let me know how you solved this.

Thanks!
Oscar
Reply all
Reply to author
Forward
0 new messages