-
Notifications
You must be signed in to change notification settings - Fork 0
/
replace_wklic01.ps1
82 lines (57 loc) · 2.39 KB
/
replace_wklic01.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Ignore error about non-existent registry key
$erroractionpreference = 'Continue'
# Change CREO Config files
$configFiles = Get-ChildItem "C:\Creo 2.0" -filter *.psf -recurse -exclude *.dll, *.exe
foreach ($file in $configFiles)
{
(Get-Content $file.PSPath) |
Foreach-Object { $_ -replace "WKLIC01", "WKLIC09" } |
Set-Content $file.PSPath
}
# Change CREO PIM XML file
$configFiles = Get-ChildItem "C:\Creo 2.0" -filter *.xml -recurse -exclude *.dll, *.exe
foreach ($file in $configFiles)
{
(Get-Content $file.PSPath) |
Foreach-Object { $_ -replace "WKLIC01", "WKLIC09" } |
Set-Content $file.PSPath
}
# Change supporting Creo install files
$configFiles = Get-ChildItem "C:\Creo 2.0" -filter *.bat -recurse -exclude *.dll, *.exe
foreach ($file in $configFiles)
{
(Get-Content $file.PSPath) |
Foreach-Object { $_ -replace "WKLIC01", "WKLIC09" } |
Set-Content $file.PSPath
}
# Change ISODRAW Startup Preferences for all user profiles
$configFiles = Get-ChildItem "C:\users\*\Appdata\Roaming\PTC" -filter *.prf -recurse -exclude *.dll, *.exe
foreach ($file in $configFiles)
{
(Get-Content $file.PSPath) |
Foreach-Object { $_ -replace "WKLIC01", "WKLIC09" } |
Set-Content $file.PSPath
}
# Change CreoView MCAD config for all user profiles
$configFiles = Get-ChildItem "C:\users\*\Appdata\Roaming\PTC" -filter *.xml -recurse -exclude *.dll, *.exe
foreach ($file in $configFiles)
{
(Get-Content $file.PSPath) |
Foreach-Object { $_ -replace "WKLIC01", "WKLIC09" } |
Set-Content $file.PSPath
}
# Change Mathcad Prime config file
$configFiles = Get-ChildItem "C:\programdata\ptc" -filter *.config -recurse -exclude *.dll, *.exe
foreach ($file in $configFiles)
{
(Get-Content $file.PSPath) |
Foreach-Object { $_ -replace "WKLIC01", "WKLIC09" } |
Set-Content $file.PSPath
}
# If PTC_D_LICENSE_FILE exists, update its value, otherwise do nothing.
if (Get-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Session Manager\Environment' -Name PTC_D_LICENSE_FILE)
{
write-output "PTC_D_LICENSE_FILE exists"
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Session Manager\Environment' -Name PTC_D_LICENSE_FILE -Value "7788@WKLIC09"
Get-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Session Manager\Environment' -Name PTC_D_LICENSE_FILE
}