Topic: Adding App path to the Windows path variable  (Read 913 times)

Adding App path to the Windows path variable
« on: July 31, 2019, 11:55:00 PM »

texervn

  • Jr. Chef
  • **
  • Date Registered: Jul 2019
  • Posts: 46
I would like to retrieve the value of HKEY_CURRENT_USER\Environment\PATH from Win10XPE Build (Target folder) and append an app path to the end (if not appended), then write the new value back in to XPE registry.

How can we process it?

Any help please.

Re: Adding App path to the Windows path variable
« Reply #1 on: September 12, 2019, 04:09:53 PM »

Malok

  • Chef
  • ***
  • Location: Canada
  • Date Registered: Aug 2016
  • Posts: 202
This is how I do it  :smile:

Code: [Select]
[Variables]
%AddPath%=c:\this\new\Directory
[Process]
RegHiveLoad,Tmp_System,%RegSystem%
RegRead,HKLM,"Tmp_System\ControlSet001\Control\Session Manager\Environment",Path,%CurrentPath%
RegWrite,HKLM,0x2,"Tmp_System\ControlSet001\Control\Session Manager\Environment",Path,"%CurrentPath%;%AddPath%"
RegHiveUnLoad,Tmp_System

Re: Adding App path to the Windows path variable
« Reply #2 on: September 12, 2019, 09:43:19 PM »

texervn

  • Jr. Chef
  • **
  • Date Registered: Jul 2019
  • Posts: 46
This is how I do it  :smile:

Code: [Select]
[Variables]
%AddPath%=c:\this\new\Directory
[Process]
RegHiveLoad,Tmp_System,%RegSystem%
RegRead,HKLM,"Tmp_System\ControlSet001\Control\Session Manager\Environment",Path,%CurrentPath%
RegWrite,HKLM,0x2,"Tmp_System\ControlSet001\Control\Session Manager\Environment",Path,"%CurrentPath%;%AddPath%"
RegHiveUnLoad,Tmp_System

Thanks Malok the the answer. I needed this to add Python to system path and also put the same lines as you did  :smile:
(https://github.com/texervn/WinBuilder-Addons/blob/master/Plugins/Python3_XPE.script#L71)

Re: Adding App path to the Windows path variable
« Reply #3 on: September 13, 2019, 12:17:18 AM »

James

  • Grand Chef
  • *****
  • Location: USA
  • Date Registered: Dec 2017
  • Posts: 2272
« Last Edit: September 13, 2019, 12:18:18 AM by James »

Re: Adding App path to the Windows path variable
« Reply #4 on: September 13, 2019, 03:46:05 AM »

Malok

  • Chef
  • ***
  • Location: Canada
  • Date Registered: Aug 2016
  • Posts: 202
You are welcome,

The way you handle that string in your code... :thumbsup:

Re: Adding App path to the Windows path variable
« Reply #5 on: September 13, 2019, 07:20:54 AM »

texervn

  • Jr. Chef
  • **
  • Date Registered: Jul 2019
  • Posts: 46

Re: Adding App path to the Windows path variable
« Reply #6 on: September 13, 2019, 11:42:23 AM »

James

  • Grand Chef
  • *****
  • Location: USA
  • Date Registered: Dec 2017
  • Posts: 2272
Environment PATH as written by Python
Code: [Select]
RegHiveLoad,Tmp_Default,%RegDefault%
RegWrite,HKLM,0x1,Tmp_Default\Environment,PATH,%PE_Programs%\%ProgramFolder%\Scripts\;%PE_Programs%\%ProgramFolder%\
RegHiveUnLoad,Tmp_Default

Re: Adding App path to the Windows path variable
« Reply #7 on: September 13, 2019, 11:59:52 AM »

James

  • Grand Chef
  • *****
  • Location: USA
  • Date Registered: Dec 2017
  • Posts: 2272
Addition Python Windows Dir Files x64
Code: [Select]
X:\Windows\py.exe
X:\Windows\pyshellext.amd64.dll
X:\Windows\pyw.exe

Addition Python Windows Dir Files x86
Code: [Select]
X:\Windows\py.exe
X:\Windows\pyshellext.win32.dll
X:\Windows\pyw.exe

Multi-Arch Registry - Less Installer / UnInstaller Info
Code: [Select]
[Add_Registry]
Echo,"Writing %ScriptTitle% Registry Settings..."
RegHiveLoad,Tmp_Default,%RegDefault%
//
RegWrite,HKLM,0x1,Tmp_Default\Environment,PATH,%PE_Programs%\%ProgramFolder%\Scripts\;%PE_Programs%\%ProgramFolder%\
//
RegWrite,HKLM,0x1,Tmp_Default\Software\Classes\Python.File\Shell\editwithidle,MUIVerb,"&Edit with IDLE"
RegWrite,HKLM,0x1,Tmp_Default\Software\Classes\Python.File\Shell\editwithidle,Subcommands,
RegWrite,HKLM,0x1,Tmp_Default\Software\Classes\Python.File\Shell\editwithidle\shell\edit37,MUIVerb,"Edit with IDLE 3.7 (64-bit)"
RegWrite,HKLM,0x1,Tmp_Default\Software\Classes\Python.File\Shell\editwithidle\shell\edit37\command,,"#$q%PE_Programs%\%ProgramFolder%\pythonw.exe#$q -m idlelib #$q#$pL#$q #$p*"
RegWrite,HKLM,0x1,Tmp_Default\Software\Classes\Python.NoConFile\Shell\editwithidle,MUIVerb,"&Edit with IDLE"
RegWrite,HKLM,0x1,Tmp_Default\Software\Classes\Python.NoConFile\Shell\editwithidle,Subcommands,
RegWrite,HKLM,0x1,Tmp_Default\Software\Classes\Python.NoConFile\Shell\editwithidle\shell\edit37,MUIVerb,"Edit with IDLE 3.7 (64-bit)"
RegWrite,HKLM,0x1,Tmp_Default\Software\Classes\Python.NoConFile\Shell\editwithidle\shell\edit37\command,,"#$q%PE_Programs%\%ProgramFolder%\pythonw.exe#$q -m idlelib #$q#$pL#$q #$p*"
//
RegWrite,HKLM,0x1,"Tmp_Default\Software\Microsoft\Windows NT\CurrentVersion\Winlogon",ParseAutoexec,1
RegWrite,HKLM,0x1,Tmp_Default\Software\Python\PythonCore,DisplayName,"Python Software Foundation"
RegWrite,HKLM,0x1,Tmp_Default\Software\Python\PythonCore,SupportUrl,http://www.python.org/
If,%Architecture%,Equal,x64,RegWrite,HKLM,0x1,Tmp_Default\Software\Python\PythonCore\3.7,DisplayName,"Python 3.7 (64-bit)"
Else,RegWrite,HKLM,0x1,Tmp_Default\Software\Python\PythonCore\3.7,DisplayName,"Python 3.7 (32-bit)"
RegWrite,HKLM,0x1,Tmp_Default\Software\Python\PythonCore\3.7,SupportUrl,http://www.python.org/
RegWrite,HKLM,0x1,Tmp_Default\Software\Python\PythonCore\3.7,Version,3.7.4
RegWrite,HKLM,0x1,Tmp_Default\Software\Python\PythonCore\3.7,SysVersion,3.7
If,%Architecture%,Equal,x64,RegWrite,HKLM,0x1,Tmp_Default\Software\Python\PythonCore\3.7,SysArchitecture,64bit
Else,RegWrite,HKLM,0x1,Tmp_Default\Software\Python\PythonCore\3.7,SysArchitecture,32bit
RegWrite,HKLM,0x1,"Tmp_Default\Software\Python\PythonCore\3.7\Help\Main Python Documentation",,%PE_Programs%\%ProgramFolder%\Doc\python374.chm
RegWrite,HKLM,0x1,Tmp_Default\Software\Python\PythonCore\3.7\Idle,,%PE_Programs%\%ProgramFolder%\Lib\idlelib\idle.pyw
RegWrite,HKLM,0x4,Tmp_Default\Software\Python\PythonCore\3.7\IdleShortcuts,,1
RegWrite,HKLM,0x1,Tmp_Default\Software\Python\PythonCore\3.7\InstalledFeatures,dev,3.7.4150.0
RegWrite,HKLM,0x1,Tmp_Default\Software\Python\PythonCore\3.7\InstalledFeatures,Shortcuts,3.7.4150.0
RegWrite,HKLM,0x1,Tmp_Default\Software\Python\PythonCore\3.7\InstalledFeatures,exe,3.7.4150.0
RegWrite,HKLM,0x1,Tmp_Default\Software\Python\PythonCore\3.7\InstalledFeatures,lib,3.7.4150.0
RegWrite,HKLM,0x1,Tmp_Default\Software\Python\PythonCore\3.7\InstalledFeatures,test,3.7.4150.0
RegWrite,HKLM,0x1,Tmp_Default\Software\Python\PythonCore\3.7\InstalledFeatures,doc_shortcut,3.7.4150.0
RegWrite,HKLM,0x1,Tmp_Default\Software\Python\PythonCore\3.7\InstalledFeatures,doc,3.7.4150.0
RegWrite,HKLM,0x1,Tmp_Default\Software\Python\PythonCore\3.7\InstalledFeatures,tools,3.7.4150.0
RegWrite,HKLM,0x1,Tmp_Default\Software\Python\PythonCore\3.7\InstalledFeatures,tcltk,3.7.4150.0
RegWrite,HKLM,0x1,Tmp_Default\Software\Python\PythonCore\3.7\InstalledFeatures,pip,3.7.4150.0
RegWrite,HKLM,0x1,Tmp_Default\Software\Python\PythonCore\3.7\InstalledFeatures,path,3.7.4150.0
RegWrite,HKLM,0x1,Tmp_Default\Software\Python\PythonCore\3.7\InstallPath,,%PE_Programs%\%ProgramFolder%\
RegWrite,HKLM,0x1,Tmp_Default\Software\Python\PythonCore\3.7\InstallPath,ExecutablePath,%PE_Programs%\%ProgramFolder%\python.exe
RegWrite,HKLM,0x1,Tmp_Default\Software\Python\PythonCore\3.7\InstallPath,WindowedExecutablePath,%PE_Programs%\%ProgramFolder%\pythonw.exe
RegWrite,HKLM,0x1,Tmp_Default\Software\Python\PythonCore\3.7\PythonPath,,%PE_Programs%\%ProgramFolder%\Lib\;%PE_Programs%\%ProgramFolder%\DLLs\
RegHiveUnLoad,Tmp_Default

RegHiveLoad,Tmp_Software,%RegSoftware%
RegWrite,HKLM,0x1,Tmp_Software\Classes\.py,,Python.File
RegWrite,HKLM,0x1,Tmp_Software\Classes\.py,"Content Type",text/plain
RegWrite,HKLM,0x1,Tmp_Software\Classes\.pyc,,Python.CompiledFile
RegWrite,HKLM,0x1,Tmp_Software\Classes\.pyd,,Python.Extension
RegWrite,HKLM,0x1,Tmp_Software\Classes\.pyo,,Python.CompiledFile
RegWrite,HKLM,0x1,Tmp_Software\Classes\.pyw,,Python.NoConFile
RegWrite,HKLM,0x1,Tmp_Software\Classes\.pyw,"Content Type",text/plain
RegWrite,HKLM,0x1,Tmp_Software\Classes\.pyz,,Python.ArchiveFile
RegWrite,HKLM,0x1,Tmp_Software\Classes\.pyz,"Content Type",application/x-zip-compressed
RegWrite,HKLM,0x1,Tmp_Software\Classes\.pyzw,,Python.NoConArchiveFile
RegWrite,HKLM,0x1,Tmp_Software\Classes\.pyzw,"Content Type",application/x-zip-compressed
If,%Architecture%,Equal,x64,RegWrite,HKLM,0x1,Tmp_Software\Classes\CLSID\{BEA218D2-6950-497B-9434-61683EC065FE}\InprocServer32,,X:\windows\pyshellext.amd64.dll
Else,Tmp_Software\Classes\CLSID\{BEA218D2-6950-497B-9434-61683EC065FE}\InprocServer32,,X:\windows\pyshellext.win32.dll
RegWrite,HKLM,0x1,Tmp_Software\Classes\CLSID\{BEA218D2-6950-497B-9434-61683EC065FE}\InprocServer32,ThreadingModel,Apartment
//
RegWrite,HKLM,0x1,Tmp_Software\Classes\Python.ArchiveFile,,"Python Zip Application File"
RegWrite,HKLM,0x1,Tmp_Software\Classes\Python.ArchiveFile\DefaultIcon,,"#$qX:\windows\py.exe#$q,5"
RegWrite,HKLM,0x1,Tmp_Software\Classes\Python.ArchiveFile\shell\open\command,,"#$qX:\windows\py.exe#$q #$q#$pL#$q #$p*"
RegWrite,HKLM,0x1,Tmp_Software\Classes\Python.ArchiveFile\shellex\DropHandler,,{BEA218D2-6950-497B-9434-61683EC065FE}
RegWrite,HKLM,0x1,Tmp_Software\Classes\Python.CompiledFile,,"Compiled Python File"
RegWrite,HKLM,0x1,Tmp_Software\Classes\Python.CompiledFile\DefaultIcon,,"#$qX:\windows\py.exe#$q,2"
RegWrite,HKLM,0x1,Tmp_Software\Classes\Python.CompiledFile\shell\open\command,,"#$qX:\windows\py.exe#$q #$q#$pL#$q #$p*"
RegWrite,HKLM,0x1,Tmp_Software\Classes\Python.CompiledFile\shellex\DropHandler,,{BEA218D2-6950-497B-9434-61683EC065FE}
RegWrite,HKLM,0x1,Tmp_Software\Classes\Python.Extension,,"Python Extension Module"
RegWrite,HKLM,0x1,Tmp_Software\Classes\Python.Extension\DefaultIcon,,"#$qX:\windows\py.exe#$q,3"
RegWrite,HKLM,0x1,Tmp_Software\Classes\Python.File,,"Python File"
RegWrite,HKLM,0x1,Tmp_Software\Classes\Python.File\DefaultIcon,,"#$qX:\windows\py.exe#$q,1"
RegWrite,HKLM,0x1,Tmp_Software\Classes\Python.File\shell\open\command,,"#$qX:\windows\py.exe#$q #$q#$pL#$q #$p*"
RegWrite,HKLM,0x1,Tmp_Software\Classes\Python.File\shellex\DropHandler,,{BEA218D2-6950-497B-9434-61683EC065FE}
RegWrite,HKLM,0x1,Tmp_Software\Classes\Python.NoConArchiveFile,,"Python Zip Application File (no console)"
RegWrite,HKLM,0x1,Tmp_Software\Classes\Python.NoConArchiveFile\DefaultIcon,,"#$qX:\windows\py.exe#$q,5"
RegWrite,HKLM,0x1,Tmp_Software\Classes\Python.NoConArchiveFile\shell\open\command,,"#$qX:\windows\pyw.exe#$q #$q#$pL#$q #$p*"
RegWrite,HKLM,0x1,Tmp_Software\Classes\Python.NoConArchiveFile\shellex\DropHandler,,{BEA218D2-6950-497B-9434-61683EC065FE}
RegWrite,HKLM,0x1,Tmp_Software\Classes\Python.NoConFile,,"Python File (no console)"
RegWrite,HKLM,0x1,Tmp_Software\Classes\Python.NoConFile\DefaultIcon,,"#$qX:\windows\py.exe#$q,1"
RegWrite,HKLM,0x1,Tmp_Software\Classes\Python.NoConFile\shell\open\command,,"#$qX:\windows\pyw.exe#$q #$q#$pL#$q #$p*"
RegWrite,HKLM,0x1,Tmp_Software\Classes\Python.NoConFile\shellex\DropHandler,,{BEA218D2-6950-497B-9434-61683EC065FE}
//
If,%Architecture%,Equal,x64,RegWrite,HKLM,0x1,Tmp_Software\Wow6432Node\Python\PyLauncher,InstallDir,X:\windows\
Else,RegWrite,HKLM,0x1,Tmp_Software\Python\PyLauncher,InstallDir,X:\windows\
If,%Architecture%,Equal,x64,RegWrite,HKLM,0x4,Tmp_Software\Wow6432Node\Python\PyLauncher,AssociateFiles,1
Else,RegWrite,HKLM,0x4,Tmp_Software\Python\PyLauncher,AssociateFiles,1
If,%Architecture%,Equal,x64,RegWrite,HKLM,0x1,Tmp_Software\Wow6432Node\Python\PyLauncher,,X:\windows\py.exe
else,RegWrite,HKLM,0x1,Tmp_Software\Python\PyLauncher,,X:\windows\py.exe
RegHiveUnLoad,Tmp_Software

RegHiveLoad,Tmp_System,%RegSystem%
RegWrite,HKLM,0x4,Tmp_System\ControlSet001\Control\FileSystem,LongPathsEnabled,1
RegWrite,HKLM,0x4,Tmp_System\ControlSet001\Control\MUI\StringCacheSettings,StringCacheGeneration,2
RegHiveUnLoad,Tmp_System
« Last Edit: September 13, 2019, 12:03:20 PM by James »

Re: Adding App path to the Windows path variable
« Reply #8 on: September 14, 2019, 04:47:00 AM »

texervn

  • Jr. Chef
  • **
  • Date Registered: Jul 2019
  • Posts: 46
Wow! Your information is very detail and includes almost all possible features.
Let me discuss a few things here:

1. These files are used to click-n-run .py file extension and also integrate to the shell menu.
Addition Python Windows Dir Files x64
Code: [Select]
X:\Windows\py.exe
X:\Windows\pyshellext.amd64.dll
X:\Windows\pyw.exe

Code: [Select]
RegWrite,HKLM,0x1,Tmp_Default\Software\Classes\Python.File\Shell\editwithidle,MUIVerb,"&Edit with IDLE"
RegWrite,HKLM,0x1,Tmp_Default\Software\Classes\Python.File\Shell\editwithidle,Subcommands,
RegWrite,HKLM,0x1,Tmp_Default\Software\Classes\Python.File\Shell\editwithidle\shell\edit37,MUIVerb,"Edit with IDLE 3.7 (64-bit)"
RegWrite,HKLM,0x1,Tmp_Default\Software\Classes\Python.File\Shell\editwithidle\shell\edit37\command,,"#$q%PE_Programs%\%ProgramFolder%\pythonw.exe#$q -m idlelib #$q#$pL#$q #$p*"
RegWrite,HKLM,0x1,Tmp_Default\Software\Classes\Python.NoConFile\Shell\editwithidle,MUIVerb,"&Edit with IDLE"
RegWrite,HKLM,0x1,Tmp_Default\Software\Classes\Python.NoConFile\Shell\editwithidle,Subcommands,
RegWrite,HKLM,0x1,Tmp_Default\Software\Classes\Python.NoConFile\Shell\editwithidle\shell\edit37,MUIVerb,"Edit with IDLE 3.7 (64-bit)"
RegWrite,HKLM,0x1,Tmp_Default\Software\Classes\Python.NoConFile\Shell\editwithidle\shell\edit37\command,,"#$q%PE_Programs%\%ProgramFolder%\pythonw.exe#$q -m idlelib #$q#$pL#$q #$p*"

2. These entries show us what features are installed when we ran the python installer. It may be not necessary to run python program.
Quote
Code: [Select]
RegWrite,HKLM,0x4,Tmp_Default\Software\Python\PythonCore\3.7\IdleShortcuts,,1
RegWrite,HKLM,0x1,Tmp_Default\Software\Python\PythonCore\3.7\InstalledFeatures,dev,3.7.4150.0
RegWrite,HKLM,0x1,Tmp_Default\Software\Python\PythonCore\3.7\InstalledFeatures,Shortcuts,3.7.4150.0
RegWrite,HKLM,0x1,Tmp_Default\Software\Python\PythonCore\3.7\InstalledFeatures,exe,3.7.4150.0
RegWrite,HKLM,0x1,Tmp_Default\Software\Python\PythonCore\3.7\InstalledFeatures,lib,3.7.4150.0
RegWrite,HKLM,0x1,Tmp_Default\Software\Python\PythonCore\3.7\InstalledFeatures,test,3.7.4150.0
RegWrite,HKLM,0x1,Tmp_Default\Software\Python\PythonCore\3.7\InstalledFeatures,doc_shortcut,3.7.4150.0
RegWrite,HKLM,0x1,Tmp_Default\Software\Python\PythonCore\3.7\InstalledFeatures,doc,3.7.4150.0
RegWrite,HKLM,0x1,Tmp_Default\Software\Python\PythonCore\3.7\InstalledFeatures,tools,3.7.4150.0
RegWrite,HKLM,0x1,Tmp_Default\Software\Python\PythonCore\3.7\InstalledFeatures,tcltk,3.7.4150.0
RegWrite,HKLM,0x1,Tmp_Default\Software\Python\PythonCore\3.7\InstalledFeatures,pip,3.7.4150.0
RegWrite,HKLM,0x1,Tmp_Default\Software\Python\PythonCore\3.7\InstalledFeatures,path,3.7.4150.0

My goal is to use the Core of Python so that it is enough to run python script from command line by using standard libraries.
So, to have a full support with all features of Python (dev, pip, docs, tcltk...) we need to add all your codes to.

Thanks again for your time to figure out the detail registry entries.
« Last Edit: September 14, 2019, 05:58:00 AM by texervn »

Re: Adding App path to the Windows path variable
« Reply #9 on: September 14, 2019, 11:49:40 AM »

James

  • Grand Chef
  • *****
  • Location: USA
  • Date Registered: Dec 2017
  • Posts: 2272
here is the full registry capture - un-edited

 

Powered by EzPortal