Jump to content


Recommended Posts

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]!

REGADD.PNG

MODEL_Key.PNG

smsts.PNG

TS.PNG

Share this post


Link to post
Share on other sites

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"

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

 

 

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

Share this post


Link to post
Share on other sites

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

Model6432Reg_Error3.PNG

Model6432Reg_Error1.PNG

Model6432Reg_Error2.PNG

Share this post


Link to post
Share on other sites

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 by TrialandError
Forgot to link Jorgen's Site

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.