NEW在SC Env变量没有得到创建脚本CM

leo815

leo815

Member
12
0
1
Hi team,

I am currently working on a software prerequisites deployment and I have a following script that doesn't create the user environment variable but creates the C:\Scratch folder. I have even tried replacing the first line in the script with setx VALUE KEY but still doesn't work. I can get setx and [System.Environment] power shell command to work directly on the PC but need it to deploy via script as I want to create this environment variable and create c:\scratch folder in one hit.
Any assistance would be appreciated. Thanks.

[System.Environment]::SetEnvironmentVariable('VALUE,'KEY',[System.EnvironmentVariableTarget]::User)
$f1 = "C:\SCRATCH"
New-Item $f1 -Type Directory
$rule=new-object System.Security.AccessControl.FileSystemAccessRule ("BUILTIN\Users","FullControl","ContainerInherit,ObjectInherit","None","Allow")
$FolderACL = Get-ACL -Path $f1
$FolderACL.SetAccessRule($rule)
Set-ACL -Path $f1 -AclObject $FolderACL
Garth

Garth

Well-Known Member
Staff member
1,841
157
63
How exactly are you deploying this? Did you test your script using the local system account? are you deploying to to the user or the device?

Forum statistics

Threads
5,754
Messages
22,435
Members
12,600
Latest member
Northshadow