0

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.

  • This sounds suspiciously like an XY problem. What is it that you're trying to accomplish? Where will this script run? If it's in an AD environment, you can probably use group policy to accomplish your goal. – austinian Jul 27 '15 at 18:33
  • @austinian true, I use it in AD environment and yes under group policy. It was a temporary solution, and I was thinking to make it as vbs. – maytham-ɯɐɥʇʎɐɯ Jul 27 '15 at 20:56
  • @austinian I disagree with you regarding XY problem, this reg is working fine. We are going move every thing to VBS so we have master VBS for login script as vbs, but I wanted to start testing .reg and see how it works as vbs, and quietly convert the rest of the login script. If you think this is the wrong way to go, I would like to hear your opinion. – maytham-ɯɐɥʇʎɐɯ Jul 27 '15 at 21:02
  • 1
    I completely understand, I've got several perfectly working vbscripts hanging around that are on the list of things to fix with a deadline of eventually. I highly recommend learning Powershell. It's not only available in 2003 up to version 2, but each successive version gets more and more powerful in its management capabilities, and in Windows 7+, you can even run your logon scripts asynchronously, so that the users don't have to wait for scripts to finish executing before their environment continues to load. – austinian Jul 27 '15 at 23:00
  • 1
    Check out this article for a nice hybrid approach of GPO and scripted login. – austinian Jul 27 '15 at 23:00
2

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 
  • 1
    I don't know enough to say. I think if this is for your personal machine or for a single machine basis, it's better in Super User. Server Fault is generally for managing larger information systems. – Michael Bailey Jul 27 '15 at 16:41
  • @maytham I improved my answer in a much more catch-all manner. – Michael Bailey Jul 27 '15 at 19:57
  • jagspage.wordpress.com/2013/08/09/… and webcache.googleusercontent.com/… both explain how to do it in VBS in multiple ways, most of which invoke ShellRun, which will literally run as you would run in Command Line. – Michael Bailey Jul 27 '15 at 19:58
  • To make the answer more complete and less reliant on the link as an answer and more as a source, you should include the vbs objects that can be used to modify the registry. For instance, GetObject("winmgmts:\\.\root\default:StdRegProv") if you use WMI to modify the registry, or CreateObject("WScript.Shell") if you want to use a shell object to modify the registry. – austinian Jul 27 '15 at 20:26
  • 1
    It's already accepted but God forbid someone comes and somehow can't use powershell and batch, I'll include the content of one or two of those links.. I understand where you're coming from. – Michael Bailey Jul 27 '15 at 23:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.