chrisray12
(chrisray12)
1
I wrote the following batch file based on a previous one written by a co-worker. The first set only displays the information. What I want is to not only display the original data but be prompted to enter in the new data and have the batch file change/update it in the registry.
@echo off
:start
set /p com=ENTER COMPUTERNAME =
reg query “\%com%\hklm\software\microsoft\windows nt\currentversion\winlogon” /v DefaultUserName
pause
set /p com=ENTER DEFAULTUSERNAME =
reg ADD “\%com%\hklm\software\microsoft\windows nt\currentversion\winlogon” /v DefaultUserName
pause
goto start
As I’m a complete novice, I have no idea if it will work or make a mess of things.
3 Spice ups
Neally
(Neally)
2
Welcome.
Does it need to be batch?
What is the OS?
I’d recommend looking into PowerShell.
chrisray12
(chrisray12)
3
With the current batch file I’m trying to fix, I get the error: “The Network path was not found.”
chrisray12
(chrisray12)
4
Windows 7 OS. Enterprise environment.
I am not familiar with how to write a script in powershell. I’m trying to make the process of entering in a default username and setting up auto logon for some contractors (temps) and I don’t know enough about powershell to give them access. I want to limit their access to remain within confines of the script so they don’t muck up the registry.
kevinbade
(knope101)
5
Let me first say that I do not know that I like this plan. But, if you must…
Take a look at what you have:
@echo off
:start
set /p com=ENTER COMPUTERNAME =
reg query "\\%com%\hklm\software\microsoft\windows nt\currentversion\winlogon" /v DefaultUserName
pause
set /p com=ENTER DEFAULTUSERNAME =
reg ADD "\\%com%\hklm\software\microsoft\windows nt\currentversion\winlogon" /v DefaultUserName
pause
goto start
set /p com=ENTER COMPUTERNAME =
You ask the user to enter the name of the computer.
reg query "\\%com%\ ...
You query a registry at that computer.
set /p com=ENTER DEFAULTUSERNAME =
You then ask the user to enter the name of a user reusing the same ‘com’ variable
reg ADD "\\%com%\hklm ...
Then you go to add the registry value. But, unless you have the name of a computer which matches the name of the user you entered, it stands to reason you get a network path error.
Edit: Hopefully increased readability/clarity.
1 Spice up