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.
Пожалуйста, сообщите.
Редактировать: 9/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"
}
Редактировать: 9/7/2019 14:09 вечера
Спасибо за помощь! Я думаю, что мы получили это. В итоге мы вручную добавили значения ключей 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 #
}