Skip to content

Commit 58761ba

Browse files
malayakusraman4
authored andcommitted
ZC v1012 : Major Bug Fixes in Windows Display Virtualization
1 parent dab92a9 commit 58761ba

36 files changed

+4996
-4899
lines changed

DVInstaller.ps1

Lines changed: 71 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#--------------------------------------------------------------------------*/
77

88
#check if file present
9+
$global:maxcount = 30
910
function is_present($filepath)
1011
{
1112
$isavailable = Test-Path $filepath
@@ -30,6 +31,54 @@ function check_executables()
3031
return "FAIL"
3132
}
3233

34+
function start_dvenabler()
35+
{
36+
#before removing the existing dvserver.dll, check if the dll is running as service
37+
#if it is running, then kill the service and then remove the dll.
38+
$status = tasklist /m | findstr "DVEnabler.dll"
39+
if ($status) {
40+
Write-Host "Kill the process before replacing the DVEnabler.dll"
41+
taskkill /F /FI "MODULES eq DVEnabler.dll" /T
42+
}
43+
44+
Remove-Item -path C:\Windows\System32\DVEnabler.dll -ErrorAction SilentlyContinue
45+
$count = 0
46+
47+
rundll32.exe DVEnabler.dll,dvenabler_init
48+
# Before Rebooting the system, we need to make sure that DVEnabler.dll has been kick started
49+
# So adding a loop with a counter of maxcount = 30, To check if DVEnabler has started
50+
# If DVEnabler doesnt get started before 30 iteration, we will exit the script.
51+
while($count -lt $maxcount){
52+
$dve = tasklist /m | findstr "DVEnabler.dll"
53+
if ($dve) {
54+
Write-Host "DVEnabler started as service ."
55+
break
56+
} else {
57+
Write-Host "Starting DVEnabler... Please wait..."
58+
$count ++
59+
continue
60+
}
61+
}
62+
if (!$dve) {
63+
Write-Host "unable to start DVEnabler... returning failure"
64+
return "FAIL"
65+
}
66+
67+
#During system login, DVEnabler service will look for this DLL in system32 path,
68+
#This will load the previously saved display topology.
69+
#Copying DVEnabler.DLL to system32 is required as part of the installation
70+
cp DVEnabler.dll C:\Windows\System32
71+
72+
#regiter a task to start the dvenabler.dll as a service during every user logon
73+
unregister-scheduledtask -TaskName "DVEnabler" -confirm:$false -ErrorAction SilentlyContinue
74+
$ac = New-ScheduledTaskAction -Execute "rundll32.exe" -Argument "C:\Windows\System32\DVEnabler.dll,dvenabler_init"
75+
$tr = New-ScheduledTaskTrigger -AtLogOn
76+
$pr = New-ScheduledTaskPrincipal -Groupid "INTERACTIVE"
77+
Register-ScheduledTask -TaskName "DVEnabler" -Trigger $tr -TaskPath "\Microsoft\Windows\DVEnabler" -Action $ac -Principal $pr
78+
79+
return "SUCCESS"
80+
}
81+
3382
##Main##
3483
$ret = check_executables
3584
if ($ret -eq "FAIL") {
@@ -41,47 +90,35 @@ else {
4190

4291
Write-Host "Start Zerocopy Driver installation..."
4392
pnputil.exe /add-driver .\DVServer\DVServerKMD.inf /install
44-
45-
Write-Host "Checking DVServer loaded successfully..."
46-
while($true){
47-
$count= (Get-Process WUDFHost | select -ExpandProperty modules | group -Property FileName | select name | Select-String -Pattern 'dvserver.dll' -AllMatches).matches.count
48-
if ($count -eq 1) {
93+
$count = 0
94+
# Before starting DVEnabler.dll we should make sure that DVServer UMD has started or not
95+
# So adding a loop with a counter of maxcount = 30, To check if DVServer UMD has started
96+
# if DVserver UMD doesnt get started before 30 iteration, we will exit the script
97+
while($count -lt $maxcount){
98+
$dvs= tasklist /m | findstr "dvserver.dll"
99+
if ($dvs) {
100+
Write-Host "DVServer loaded successfully..."
49101
break
50-
}
51-
else{
102+
} else {
103+
Write-Host "DVServer loading...Please wait..."
104+
$count ++
52105
continue
53106
}
54107
}
55-
56-
Write-Host "creating DVEnabler Task and running it as service ..."
57-
58-
Remove-Item -path C:\Windows\System32\DVEnabler.dll
59-
60-
rundll32.exe DVEnabler.dll,dvenabler_init
61-
while($true){
62-
$DVE = tasklist /m | findstr "DVEnabler.dll"
63-
if ($DVE) {
64-
Write-Host "DvEnabler started as service ."
65-
break
66-
}
67-
else{
68-
Write-Host " Dvenabler not yet started. Please wait..."
69-
continue
70-
}
108+
if (!$dvs) {
109+
Write-Host "Failed to load DVServer UMD... Exiting"
110+
Exit
71111
}
72112

73-
cp DVEnabler.dll C:\Windows\System32
74-
unregister-scheduledtask -TaskName "DVEnabler" -confirm:$false -ErrorAction SilentlyContinue
75-
$ac = New-ScheduledTaskAction -Execute "rundll32.exe" -Argument "C:\Windows\System32\DVEnabler.dll,dvenabler_init"
76-
$tr = New-ScheduledTaskTrigger -AtLogOn
77-
$pr = New-ScheduledTaskPrincipal -Groupid "INTERACTIVE"
78-
Register-ScheduledTask -TaskName "DVEnabler" -Trigger $tr -TaskPath "\Microsoft\Windows\DVEnabler" -Action $ac -Principal $pr
79-
if ($LASTEXITCODE -eq 0) {
80-
Write-Host "DVEnabler Success. DVServerUMD has taken over MSBDA!"
113+
#call start_dvnabler to run the dvenabler.sll as a service
114+
$dve = start_dvenabler
115+
if ($dve -eq "SUCCESS") {
116+
Write-Host "Dvnabler succusfully started...."
117+
Write-Host "Rebooting Windows VM..."
118+
Restart-Computer
81119
} else {
82-
Write-Host "DVEnabler failed. DVServerUMD has not taken over MSBDA!"
120+
Write-Host "Fail to start Dvnabler.... Exiting!"
121+
Exit
83122
}
84123

85-
Write-Host "Rebooting Windows VM..."
86-
Restart-Computer
87124
}

0 commit comments

Comments
 (0)