-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfusion-log.csx
More file actions
53 lines (50 loc) · 2.13 KB
/
Copy pathfusion-log.csx
File metadata and controls
53 lines (50 loc) · 2.13 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
bool toggleFusionLog, enableFusionLog;
var args = Environment.GetCommandLineArgs();
ProcessArguments(args, ref toggleFusionLog, ref enableFusionLog);
const string keyName = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion";
if (toggleFusionLog)
{
object currentState = Microsoft.Win32.Registry.GetValue(keyName, "EnableLog", 0);
Console.WriteLine("FusionLog was " + (currentState.Equals(1) ? "enabled..." : "disabled..."));
enableFusionLog = currentState.Equals(1) ? false : true;
}
if (enableFusionLog)
{
var location = Path.Combine(Path.GetTempPath(), "FusionLog");
System.IO.Directory.CreateDirectory(location);
Microsoft.Win32.Registry.SetValue(keyName, "ForceLog", 1, Microsoft.Win32.RegistryValueKind.DWord);
Microsoft.Win32.Registry.SetValue(keyName, "LogFailures", 1, Microsoft.Win32.RegistryValueKind.DWord);
Microsoft.Win32.Registry.SetValue(keyName, "LogResourceBinds", 1, Microsoft.Win32.RegistryValueKind.DWord);
Microsoft.Win32.Registry.SetValue(keyName, "EnableLog", 1, Microsoft.Win32.RegistryValueKind.DWord);
Microsoft.Win32.Registry.SetValue(keyName, "LogPath", location, Microsoft.Win32.RegistryValueKind.String);
Console.WriteLine("FusionLog is enabled. Logs are located at " + location);
}
else
{
Microsoft.Win32.Registry.SetValue(keyName, "ForceLog", 0, Microsoft.Win32.RegistryValueKind.DWord);
Microsoft.Win32.Registry.SetValue(keyName, "LogFailures", 0, Microsoft.Win32.RegistryValueKind.DWord);
Microsoft.Win32.Registry.SetValue(keyName, "LogResourceBinds", 0, Microsoft.Win32.RegistryValueKind.DWord);
Microsoft.Win32.Registry.SetValue(keyName, "EnableLog", 0, Microsoft.Win32.RegistryValueKind.DWord);
Console.WriteLine("FusionLog is disabled.");
}
void ProcessArguments(string[] args, ref bool toggle, ref bool enable)
{
if (args.Length > 2)
{
var desiredState = args[2];
if (desiredState == "0")
{
toggle = false;
enable = false;
return;
}
else if (desiredState == "1")
{
toggle = false;
enable = true;
return;
}
}
toggle = true;
return;
}