vincelewin Posted June 5, 2017 Report post Posted June 5, 2017 Hi all, Im running SCCM 1702, client is windows 10 64. I am struggling with an issue related to registry redirector on windows 64bit os. I have created a batch file that queries WMI for the model, in this case of my dell laptops, and then creates a registry key using the "REG ADD" command in HKLM\Software\Microsoft\CurrentVersion\Model REG_SZ. EG 7440. I've deployed this as a package and now can see the registry key in the WOW6432Node key! I have then created a Task Sequence, and on the parent group, set an evaluation on this registry key HKLM\Software\Microsoft\CurrentVersion\Model and also on HKLM\Software\WOW6432Node\Microsoft\CurrentVersion\Model so that if the model number in the reg key is greater than 7440 then the TS will continue to run. I have used an OR condition. I hoped this would query both but it seems to only look in the HKLM\Software\Microsoft\CurrentVersion\ node. I have deployed this but can see on my test laptop in the SMSTS.log file the following <![LOG[Registry value HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Model does not exist]LOG]! and then <![LOG[The group (Is the device higer than E7440) has been skipped because the condition is evaluated to be false]LOG]! Quote Share this post Link to post Share on other sites More sharing options...
Dudi Posted June 5, 2017 Report post Posted June 5, 2017 the client always run in 32Bit, this will solve the issue if %AddressWidth%==64 ( echo "64 bit ENV" Set ENV=%windir%\syswow64 ) else ( echo "32 bit ENV" set ENV=%windir%\system32 ) %ENV%\reg import "%~dp0PS_Bypass.reg" Quote Share this post Link to post Share on other sites More sharing options...
vincelewin Posted June 5, 2017 Report post Posted June 5, 2017 Hi Dudi, Thanks. should I put that before my script? Ie. if %AddressWidth%==64 ( echo "64 bit ENV" Set ENV=%windir%\syswow64) else ( echo "32 bit ENV" set ENV=%windir%\system32)%ENV%\reg import "%~dp0PS_Bypass.reg" FOR /F "tokens=2* delims=E" %%A IN ('WMIC ComputerSystem GET Model /Value') DO REG ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion /f /v Model /t REG_SZ /d %%A exit Quote Share this post Link to post Share on other sites More sharing options...
Dudi Posted June 5, 2017 Report post Posted June 5, 2017 64Bit OS got two version of reg.exe, this WMI query and change the value of %reg% between %windir%\system32 or r%\syswow64 according to the OS version. BTW, this will work only in the TS and not in simple batch file. c:\windows\system32\reg.exe or c:\windows\syswow64\reg.exe #--------------------------------------- if %AddressWidth%==64 ( echo "64 bit ENV" Set ENV=%windir%\syswow64 ) else ( echo "32 bit ENV" set ENV=%windir%\system32 ) FOR /F "tokens=2* delims=E" %%A IN ('WMIC ComputerSystem GET Model /Value') DO %ENV%\REG.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion /f /v Model /t REG_SZ /d %%A Quote Share this post Link to post Share on other sites More sharing options...
vincelewin Posted June 6, 2017 Report post Posted June 6, 2017 Hi Dudi, I tried this two ways. I created a new script *.cmd, placed inside a package and created a new TS. I used the command line option and entered the script name and the package but this fails with the error ) is not expected at this time. I tried with and without cmd /c. I also tried just entering the full command from the script into the command box inside the TS without the Package defined but this replaces the %A from %Addresswidth% with a number and returns an error "The file could not be found!". Any ideas on which solution I should chase and what I should do to resolve the errors? I've attached screen grabs. Thanks Vince Quote Share this post Link to post Share on other sites More sharing options...
TrialandError Posted June 6, 2017 Report post Posted June 6, 2017 (edited) I'm not entirely following your logic here. Are you trying to tattoo the registry with the model of the computer during the task sequence and then use that value as a condition for other steps in the task sequence? Why not just query the model via WMI and use that as a conditional statement? Either way you don't need to echo anything in your batch script. It's not like you are going to see the results on the screen. Also you're writing the value as a string so I'm not sure "greater than" will work like you want it too. Check out Jorgen's tattoo method - it works well. You can do more troubleshooting by pausing the task sequence and running these scripts manually until you get the results you are looking for. I also simplified the script you are currently trying to use though I don't think it is the best way to accomplish what you are trying to do. @echo off for /f "tokens=2* delims=E" %%f in ('WMIC ComputerSystem GET Model /value') do set "Model=%%f" if "%PROCESSOR_ARCHITECTURE%"=="AMD64" ( Set ENV=%windir%\syswow64) else ( Set ENV=%windir%\system32) %ENV%\REG.exe ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion" /v Model /t REG_SZ /d "%Model%" /f Edited June 6, 2017 by TrialandError Forgot to link Jorgen's Site Quote Share this post Link to post Share on other sites More sharing options...
vincelewin Posted June 7, 2017 Report post Posted June 7, 2017 Hi and thanks for that. I wrote a script, yes to tatoo the model number in the registry, via a deployed Package before the event. Later I will deploy the task sequence that will only run if the registry key is greater than or equal to 7440. Should I create a DWORD Key for the model? I knew about the echo but thought I would remove it once I had a running solution! Ill try your script out. Thx. P.S. The model in wmi is from memory Lattitude E7440 so my original solution was searching the wmi response to find the position of E and then saving the chars after that to a variable and putting it into a registry key. It all looked like it was working except the package/script wrote to the 64 bit registry and the TS reads the 32bit registry and reports the key does not exist. Quote Share this post Link to post Share on other sites More sharing options...
vincelewin Posted June 7, 2017 Report post Posted June 7, 2017 Again the variable just gets converted to a long number Failed to execute command line 'for /f "tokens=2* delims=E" 0.000000 in ('WMIC ComputerSystem GET Model /value') do set "Model=0.000000" if "AMD64"=="AMD64" ( Set ENV=C:\WINDOWS\syswow64) else ( Set ENV=C:\WINDOWS\system32) 6.894164E-317NV\REG.exe ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion" /v Model /t REG_SZ /d "Model" /f' . The system cannot find the file specified. (Error: 80070002; Source: Windows) Quote Share this post Link to post Share on other sites More sharing options...
vincelewin Posted June 7, 2017 Report post Posted June 7, 2017 I think ive made progress now. Im no longer receiving the Key does not exist error but it failing to evaluate the => I have set so I guess that could be because its a string in the registry. I have called the script in a package via a TS. Im going to try using a dword in the reg now and see how that goes. Quote Share this post Link to post Share on other sites More sharing options...
TrialandError Posted June 7, 2017 Report post Posted June 7, 2017 Glad you are making progress! Once you get everything working you can add the reg keys to your hardware inventory and runs reports or build collections out of them. Quote Share this post Link to post Share on other sites More sharing options...