Solved

VBS file to modify registry

Posted on 2008-10-30
7
743 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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Resolve DNS query failed errors for Exchange
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

777 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