Ethan Templeton
Ethan Templeton

Reputation: 1

Command line works fine in CMD cant get it to work through batch

I have a command that works fine in CMD but if i try and save it as a bat it quickly opens and closes CMD and nothing happens.

reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /t REG_SZ /d 0 /f"

--

reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName /t REG_SZ /d user /f"

--

reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultPassword /d 12345 /f"

These are the 3 lines and I cant work out how to get a batch to run it.

Upvotes: 0

Views: 43

Answers (1)

Compo
Compo

Reputation: 38579

As in my comment, (you should run this as administrator):

@Echo Off
Set "rKey=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
Reg Add "%rKey%" /V AutoAdminLogon /D 0 /F > Nul
Reg Add "%rKey%" /V DefaultUserName /D user /F > Nul
Reg Add "%rKey%" /V DefaultPassword /D 12345 /F >Nul

the > Nul may be omitted, if you want to see the returned message

Upvotes: 1

Related Questions