We are upgrading our Software to its 2019 version. Apparently it is a
bugger, so it has been suggested to do a clean install including deleting
some registry keys from previous versions.
We also want to save the autologins of our users so they don't need to
reset them up and we can also do something similar with new deployments.
I got some code working for what we want to do, but the problem is that
when I went to add it to our uninstall script, the uninstall script has
some different paths using HKEY_USERS vs my HKCU.
如何修改我的代码以适合正在使用的卸载脚本 HKEY_USERS?
除了原始代码外,没有尝试过其他任何方法。不知道在哪里 开始。这是我第一次尝试使用powershell(或其他任何编码)。
#Basically this is supposed to grab the users autologin key, save it,
#then after nuking the reg, put it back
$path = 'HKCU:\Software\SolidWorks\Applications\PDMWorks
Enterprise\ServerConfig\FakeVaultName'
$autologinkey = "HKCU\Software\SolidWorks\Applications\PDMWorks
Enterprise\ServerConfig\FakeVaultName"
$user=(Get-ItemProperty -Path $path -Name User).user.ToLower()
#/y forces overwriting the existing file without prompt.
if($user -ne 'fakeusername' -and $user){
reg export $autologinkey "$env:TEMP\fakekeyname.reg" /y
}
#These next steps need to be done after the uninstall/reg scrubbing
if($user -ne 'fakeusername' -and $user){
reg.exe import "$env:TEMP\fakekeyname.reg"
}
#I think this could maybe get away with just the else part instead of
#elseif + the user?
elseif($user -eq 'fakeusername' -or !$user){
reg.exe import
"\\fakecompanyname.com\Files\Public\IT\Protected\Projects\SOLIDWORKS
2019
deployment\Vault fakeusername auto login keys.reg"
}
#I need to make my code work with the following that loops through
#all the different users on the machine (not the whole code, just the
#HKEY_USERS part that I'm concerned with
# This is where you can read/modify a users portion of the registry
$unwantedDirectories += "registry::HKEY_USERS\
{0}\Software\SolidWorks" -f
$($Item.SID)
$unwantedDirectories += "registry::HKEY_USERS\{0}\Software\SRAC" -f
$($Item.SID)
$unwantedDirectories += "registry::HKEY_USERS\{0}\Software\eDrawings"
-f
$($Item.SID)
$unwantedDirectories += "registry::HKEY_USERS\{0}\Software\SOLIDWORKS
2017" -f $($Item.SID)
我不知道从哪里开始。我的代码有效,但不确定如何绑定 与其他HKEY_USERS部分。
请告知。
编辑:7/9/2019 该脚本可以正常工作,但是它将reg键导入到已登录用户和我们想要的配置文件中。以下是当前有效的(大部分)代码。
###############################################################################
#This part is ran before the reg nuke.
$autologinpath = registry::HKEY_USERS\0}\Software\SolidWorks\Applications\PDMWorks Enterprise\ServerConfig\FakeVaultName' -f $($Item)
$autologinkey = "HKU\{0}\Software\SolidWorks\Applications\PDMWorks Enterprise\ServerConfig\FakeVaultName" -f $($Item)
$autologinuser=(Get-ItemProperty -Path $autologinpath -Name User).user.ToLower()
if($autologinuser -ne 'fakeusername' -and $autologinuser){
reg export $autologinkey "$env:TEMP\fakekeyname.reg" /y
}
###############################################################################
#This part is ran after the reg nuke.
if($user -ne 'fakeusername' -and $autologinuser){
reg.exe import "$env:TEMP\fakekeyname.reg"
}
else {
reg.exe import "\\fakecompanyname.com\Files\Public\IT\Protected\Projects\SOLIDWORKS 2019 deployment\Vault fakeusername auto login keys.reg"
}
编辑:7/9/2019 2:09 pm
感谢您的帮助!我想我们明白了。我们最终手动添加了reg键值。可能不是很优雅,但似乎可以正常工作。
Else {
reg add $autologinkey /v "SettingsFromServer" /t REG_DWORD /f /d #
reg add $autologinkey /v "User" /t REG_SZ /f /d fakeusername
reg add $autologinkey /v "Config" /t REG_BINARY /f /d blahblahblahinfinity..
reg add $autologinkey /v "CacheW" /t REG_DWORD /f /d #
reg add $autologinkey /v "SinglePointLogin" /t REG_DWORD /f /d #
}