Solved

VBS file to modify registry

Posted on 2008-10-30
7
744 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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

Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

Question has a verified solution.

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

Suggested Solutions

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 …
An article on effective troubleshooting
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

809 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