VMware Cloud Community
vimala1085
Contributor
Contributor

Add Environment variable to windows local user(.\localadmin)

Dear Team,

    I cant able to set user based environment variable.It set to the logged-in user instead of windows local user.

I have create a windows local user ".\localadmin" with appropiate rights but environment variable is set to the ".\administrator" which is logged-in user. I have tried in post-installation step also.

Could you please help me on this? iam using Installbuilder 20.12.0.

<addEnvironmentVariable>
<name>SISUITE_PORT</name>
<scope>user</scope>
<username>.\localadmin</username>
<value>1234</value>
<onErrorActionList>
<showInfo>
<text>error occured</text>
</showInfo>
</onErrorActionList>
</addEnvironmentVariable>

0 Kudos
10 Replies
michieldhont_
Hot Shot
Hot Shot

Hi @vimala1085,

Can you try <username>localadmin</username>:

<addEnvironmentVariable>
<name>SISUITE_PORT</name>
<scope>user</scope>
<username>localadmin</username>
<value>1234</value>
<onErrorActionList>
<showInfo>
<text>error occured</text>
</showInfo>
</onErrorActionList>
</addEnvironmentVariable>

 Regards,

Michiel

0 Kudos
vimala1085
Contributor
Contributor

I have tried "localadmin" , ".\localadmin" and "hostname\localadmin" eventhen it is not working. i already tried these options.

0 Kudos
vimala1085
Contributor
Contributor

Is there any update on this

0 Kudos
michieldhont_
Hot Shot
Hot Shot

Hi,
 
I've discussed the issue with our engineers. The <username> attribute is not used on Windows. As a workaround, you can directly modify the registry to modify an specific user environment referring it by its SID. The below links provides some tips on how to obtain a user SID:
 
 
Then you could use it with <registrySet>
<registrySet>
<key>HKEY_Users\${SID}\Environment</key>
<name>SISUITE_PORT</name>
<value>1234</value>
</registrySet>
 
Regards,
Michiel
0 Kudos
vimala1085
Contributor
Contributor

when i try to set environment variable using registryset command from administrator, i get "could not set registry key"

0 Kudos
michieldhont_
Hot Shot
Hot Shot

Hi @vimala1085,

We will handle this issue in the private support channel.

Regards,

Michiel

0 Kudos
vimala1085
Contributor
Contributor

Hi Team, 

Herewith i have attached debugtrace logs as you requested. yesterday itself i have uploaded the same log in ServiceRequest as well 21208415103.

Can you please look into that SR.

 

Thanks & Regards,

Vimala M

0 Kudos
vimala1085
Contributor
Contributor

SID of localadmin is not exists ie the user which we are trying to set in registry is not there. only the SID of logged-in user is present. If i logged into the windows local user(localadmin) then only i can able to view that SID entry of the windows localadmin in the registry.

Is it the behaviour of windows?

I could not reply for the ServiceRequest  SR 21208415103 as i dont have permission.

Thanks for your reply

0 Kudos
michieldhont_
Hot Shot
Hot Shot

Hi @vimala1085,

I've replied in private support but I will add it here as well so it can help other users. You could use wmic to get the SID of localadmin. For example:

        <runProgram>
            <program>wmic</program>
            <programArguments>useraccount where name="localadmin" get sid</programArguments>
        </runProgram>
        <!-- we only want the actual SID from the wmic output -->
        <setInstallerVariableFromRegEx>
            <name>userSid</name>
            <pattern>.*(S[0-9-]+).*</pattern>
            <text>${program_stdout}</text>
            <substitution>\1</substitution>
        </setInstallerVariableFromRegEx>
        <!-- use the variable in the registrySet action -->
        <registrySet>
            <key>HKEY_USERS\${userSid}\Environment</key>
            <name>sisuite_test</name>
            <type>REG_SZ</type>
            <value>1234</value>
        </registrySet>

Regards,

Michiel

0 Kudos
vimala1085
Contributor
Contributor

As you suggested it is not working. If we try to set registry key of one user(windows local user) from another user then it could not set registry key.

Anyhow i am attaching the screenshot again. Then only you will come to know the exact issue.

Can you please try in your local machine by creating windows local user from your logged-in user(both users are different) and try to set registry key from your logged-in user to another user.

0 Kudos