forked from adamdriscoll/PoshInternals
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlueScreen.ps1
More file actions
61 lines (49 loc) · 2.07 KB
/
BlueScreen.ps1
File metadata and controls
61 lines (49 loc) · 2.07 KB
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
<#
.Synopsis
Installs a blue screen screensaver that mimics the Windows 8 system fault blue screen.
.DESCRIPTION
Installs a blue screen screensaver that mimics the Windows 8 system fault blue screen. This cmdlet
compiles a custom C# PowerShell SCR file to the system directory that can be used to host any PowerShell
script. The PowerShell script is responsible for displaying the screen saver.
You must run this cmdlet from an elevated PowerShell host.
.EXAMPLE
Install-BlueScreenSaver
#>
function Install-BlueScreenSaver
{
$CSharp =
'
using System;
using System.Windows.Forms;
using System.Management.Automation;
using System.Management.Automation.Runspaces;
public class Program
{
static void Main(string[] args)
{
using (var runSpace = RunspaceFactory.CreateRunspace())
{
runSpace.Open();
using (var pipeline = runSpace.CreatePipeline("C:\\windows\\syswow64\\ScreenSaver.ps1"))
{
pipeline.Invoke();
}
}
}
}
'
$tmpFile = [IO.Path]::GetTempFileName() + ".cs"
Out-File -FilePath $tmpFile -InputObject $CSharp
Start-Process -FilePath C:\windows\Microsoft.NET\Framework\v4.0.30319\csc.exe -ArgumentList "/out:bluescreen.exe","/r:`"C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Management.Automation\v4.0_3.0.0.0__31bf3856ad364e35\System.Management.Automation.dll`"",$tmpFile -Wait
Rename-Item "bluescreen.exe" "bluescreen.scr"
$System32 = Join-Path $env:SystemRoot "System32"
Copy-Item "bluescreen.scr" (Join-Path $System32 "bluescreen.scr")
Copy-Item "ScreenSaver.ps1" (Join-Path $System32 "ScreenSaver.ps1")
if ($env:PROCESSOR_ARCHITECTURE -eq "AMD64")
{
$System32 = Join-Path $env:SystemRoot "SysWow64"
Copy-Item "bluescreen.scr" (Join-Path $System32 "bluescreen.scr")
Copy-Item "ScreenSaver.ps1" (Join-Path $System32 "ScreenSaver.ps1")
}
Remove-Item "bluescreen.scr"
}