Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
LesFerch authored Nov 23, 2024
1 parent 0442896 commit a1f8587
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 0 deletions.
68 changes: 68 additions & 0 deletions Tools/CaptureCustom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// This script captures keys that may contain settings beyond what can be set in WinSetView.
// The reg file created by this script can be renamed to WinSetViewCustom.reg and placed in the
// WinSetView AppData folder to provide additional custom settings.
// If you don't know what you're doing, please do not use this extra level of customization!

ForReading = 1;
ForWriting = 2;
Unicode = -1;
Ansi = 0;
vbCancel = 2;
vbOKCancel = 1;
vbInformation = 64;
Z = "\r\n"; ZZ = Z + Z;

oWSH = WScript.CreateObject("Wscript.Shell");
oFSO = WScript.CreateObject("Scripting.FileSystemObject");

function MsgBox(prompt, buttons, title) {
oWSH.Popup(prompt, 0, title, buttons);
}

Temp = oWSH.ExpandEnvironmentStrings("%Temp%");
TempFile = Temp + "\\WinSetView.tmp";
CaptureFile = ".\\WinSetViewCustom.reg";

CPan = "\"" + "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ControlPanel" + "\"";
BagM = "\"" + "HKCU\\Software\\Classes\\Local Settings\\Software\\Microsoft\\Windows\\Shell\\BagMRU" + "\"";
Bags = "\"" + "HKCU\\Software\\Classes\\Local Settings\\Software\\Microsoft\\Windows\\Shell\\Bags" + "\"";

RetVal = MsgBox("This is an optional configuration tool for power users." + ZZ + "Click OK to capture keys ControlPanel, BagMRU, and Bags to: " + CaptureFile, vbOKCancel, WScript.ScriptName);
if (RetVal == vbCancel) WScript.Quit();

oOutput = oFSO.OpenTextFile(CaptureFile, ForWriting, true, Ansi);

oOutput.Write("Windows Registry Editor Version 5.00" + ZZ);
oOutput.Write("; Place this file in your WinSetView AppData folder to have it applied by WinSetView." + Z);

oWSH.Run("Reg Export " + CPan + " " + TempFile + " /y", 0, true);

oInput = oFSO.OpenTextFile(TempFile, ForReading, false, Unicode);
while (!oInput.AtEndOfStream) {
Line = oInput.ReadLine();
if (Line != "Windows Registry Editor Version 5.00") oOutput.Write(Line + Z);
}
oInput.Close();

oWSH.Run("Reg Export " + BagM + " " + TempFile + " /y", 0, true);

oInput = oFSO.OpenTextFile(TempFile, ForReading, false, Unicode);
while (!oInput.AtEndOfStream) {
Line = oInput.ReadLine();
if (Line != "Windows Registry Editor Version 5.00") oOutput.Write(Line + Z);
}
oInput.Close();

oWSH.Run("Reg Export " + Bags + " " + TempFile + " /y", 0, true);

oInput = oFSO.OpenTextFile(TempFile, ForReading, false, Unicode);
while (!oInput.AtEndOfStream) {
Line = oInput.ReadLine();
if (Line.indexOf("\\AllFolders") != -1) break;
if (Line != "Windows Registry Editor Version 5.00") oOutput.Write(Line + Z);
}
oInput.Close();

oOutput.Close();

MsgBox("Done. See file: " + CaptureFile, vbInformation, WScript.ScriptName);
25 changes: 25 additions & 0 deletions Tools/WinSetView.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
INIFile = "";
// INIFile = ".\\Win10.ini";
if (WScript.Arguments.length > 0) INIFile = WScript.Arguments(0);

oWSH = WScript.CreateObject("Wscript.Shell");
oFSO = WScript.CreateObject("Scripting.FileSystemObject");

MyPath = oFSO.GetParentFolderName(WScript.ScriptFullName)
oWSH.CurrentDirectory = MyPath;
Z = "\r\n"; ZZ = Z + Z;

function MsgBox(prompt, buttons, title) {
oWSH.Popup(prompt, 0, title, buttons);
}

if (!oFSO.FileExists(INIFile)) {
Msg = "Run WinSetView.exe to create or update an INI file." + ZZ;
Msg += "Then drop the INI file on this script to run ";
Msg += "WinSetView.ps1 with the saved settings." + ZZ;
Msg += "This script can be relocated to the WinSetView AppData folder.";
MsgBox(Msg, 0 + 64, "GUI-less Execution Instructions:");
} else {
CmdLine = "Powershell.exe -ExecutionPolicy Bypass ..\\WinSetView.ps1 " + INIFile;
oWSH.Run(CmdLine, 1, false);
}

0 comments on commit a1f8587

Please sign in to comment.