Windows Registry to VBS

vbscriptwindows-registry

I have this registery (.reg) file that I use to modify screensaver properties:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Control Panel\Desktop]
"ScreenSaveActive"="1"
"ScreenSaveTimeOut"="900"
"ScreenSaverIsSecure"="1"
"SCRNSAVE.EXE"="C:\\windows\\system32\\scrnsave.scr"

The registry works fine.

My Question: is it possible to make this registry to Visual Basic Script .vbs file? If yes how, please advice.

PS this is my first question in this forum.

Best Answer

This was answered to a degree here at Super User but I recommend using reg query, reg import and reg add in MS-DOS/Command Prompt.

EDIT: To elaborate, you can manually add the keys one by one or you can import a .reg file with a simple batch script (if not a one liner)

If this is in an AD environment, it can be done, perhaps more reliably, with group policy. In an environment where there's remote management but no AD, personally what I'd do is host the .reg file on a network share and either copy it or import it directly if possible (I'm not sure if reg import supports that.

EDIT: Let's make this a bit more complete. You'd import the reg key with

reg import \\Sharename\regkey.reg

In command prompt/batch.

Here's an example I tested this solution with.

FINAL EDIT: It's been brought to my attention there's an off chance someone comes here and, in their right mind, actually wants to do this with VBS. I linked two links, but here's one of the solutions

Vbs Script:

Set oShell = CreateObject("Wscript.Shell")

'Your .Reg file and path goes here as in the example below
sRegFile = "C:\Temp\MyFile.Reg"

'This line runs Regedit in silent mode
oShell.Run "regedit.exe /s " & Chr(34) & sRegFile & Chr(34), 0, True