iamnacho Frequent Contributor.
Frequent Contributor.
156 views

System Variables while editing NTUSER.DAT from ZCM

Hello,

I'm working with ZCM 2017 U4 + FTF 1a and Windows 10 (1903 + recent updates).

I'm attempting to modify some registry entries for default/new users and am using a run script action and am defining my own script in a ZCM Bundle.  I've done this several times in the past without issue, but now I'm trying to insert registry data the contains variables ( the actual variable names like %USERNAME%, not the expanded version of the current username)  I've tried the bundle action as both secure system user and Dynamic Administrator.

Here's what I'm attempting to do:

reg load HKEY_USERS\TempUserZCM "C:\Users\Default\NTUSER.DAT"

reg ADD "HKEY_USERS\TempUserZCM\Software\Microsoft\Windows\CurrentVersion\PushNotifications\wpnidm" /v "Path" /t REG_SZ /d C:\Users\^%USERNAME^%\AppData\Local\Microsoft\Windows\Notifications\wpnidm /f

(My understanding is that ^ is used to escape the variable and should not expand it, but put it there literally)

The action succeeds, but when I query the value after the bundle, the data looks like:

"C:\Users\\AppData\Local\Microsoft\Windows\Notification\wpnidm"  - It is missing the "%USERNAME%" portion that I am attempting to set.

 

When I run these same commands outside of ZCM at command line, they work perfectly fine ( the data then reads: "C:\Users\%USERNAME%\\AppData\Local\Microsoft\Windows\Notification\wpnidm").

 

I'm at a bit of a loss.  Should this work in ZCM?

 

Thank you

Labels (1)
0 Likes
3 Replies
Micro Focus Expert
Micro Focus Expert

Re: System Variables while editing NTUSER.DAT from ZCM

What you want for a script action is the following.....

REG ADD "HKLM\Software\Acme" /f /v "Dynamic_Script_Action_User" /t REG_SZ /d "%%%USERNAME%%%"

I will post an article a bit later explaining why.....

--
Please give a hearty thumbs up to any post you find helpful!
To find articles by Craig Wilson simply follow the link: Craig Wilson's Tips!
0 Likes
iamnacho Frequent Contributor.
Frequent Contributor.

Re: System Variables while editing NTUSER.DAT from ZCM

That worked. Thank you Craig!

0 Likes
Micro Focus Expert
Micro Focus Expert

Re: System Variables while editing NTUSER.DAT from ZCM

Glad it worked for you....

FYI - Here is an article that details exactly why that worked....

https://community.microfocus.com/t5/ZENworks-Tips-Information/ZENworks-Understanding-how-to-use-Environment-Variables-in/ta-p/2703302

 

--
Please give a hearty thumbs up to any post you find helpful!
To find articles by Craig Wilson simply follow the link: Craig Wilson's Tips!
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.