Solved

VBS file to modify registry

Posted on 2008-10-30
7
747 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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

Free NetCrunch network monitor licenses!

Only on Experts-Exchange: Sign-up for a free-trial and we'll send you your permanent license!

Here is what you get: 30 Nodes | Unlimited Sensors | No Time Restrictions | Absolutely FREE!

Act now. This offer ends July 14, 2017.

Question has a verified solution.

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

A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
Determining the an SCCM package name from the Package ID
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
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…

726 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