Solved

VBS file to modify registry

Posted on 2008-10-30
7
745 Views
Last Modified: 2013-12-23
I am looking to create a simple .vbs file that will modify a registry key. I need it to have a prompt to change one key, and automatically change the other key.

The keys are
hkey_local_machine>software>microsoft>windows nt>winlogon>defaultusername
hkey_local_machine>software>microsoft>windows nt>winlogon>defaultdomainname

I need a simple prompt that will ask me for the defaultusername, and when I enter it, it will change the key with my value. And, I need it to always change the defaultdomainname to "MCPS".

I have never programmed, and I am not even sure if this is the correct way to do this. Thanks for your help!
0
Comment
Question by:dougstech
  • 4
  • 3
7 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 22851646
easy batch method:

@echo off
set /p defUser=Enter the default username:
set /p defDomain=Enter the default domain:
reg add "hklm\software\microsoft\windows nt\currentversion\winlogon /v defaultusername /d %defUser% /f
reg add "hklm\software\microsoft\windows nt\currentversion\winlogon /v defaultdomain /d %defDomain% /f
echo. Changes complete.
0
 
LVL 67

Accepted Solution

by:
sirbounty earned 125 total points
ID: 22851691
vbs method:
const HKLM = &H80000002
 
Dim objReg : Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
 
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion"
 
defUser = InputBox("Enter the default username", "Data needed")
defDomain = InputBox("Enter the default domain", "Data needed")
 
objReg.SetStringValue HKLM, strKeyPath, "DefaultUserName",defUser
objReg.SetStringValue HKLM, strKeyPath, "DefaultDomainName",defDomain
 
Set objReg = Nothing

Open in new window

0
 
LVL 5

Author Comment

by:dougstech
ID: 22857692
Both methods are superb, but I want to split points.
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 67

Expert Comment

by:sirbounty
ID: 22858675
0
 
LVL 5

Author Comment

by:dougstech
ID: 22858973
Right but 125/2=62.5. I wont let me add half points.
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 22859048
You can do 75/50 or if you want to be closer to exact 63/62.  Either way, I posted both solutions - I don't mind if you only accept one... :^)
0
 
LVL 5

Author Comment

by:dougstech
ID: 22859051
oh lol, I didn't even see that it was both you :p
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
When you try to extract and to view the contents of a Microsoft Update Standalone Package (MSU) for Windows Vista, you cannot extract the files from the MSU. Here we are going to explain how to extract those hotfix details without using any third pa…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question