【发布时间】:2022-01-23 01:52:42
【问题描述】:
我有一个批处理文件,它将运行并在运行时为每行提供成功或不成功的echo。这批中将有 1 或 0 条成功线。我希望将成功的行记录到提到的 .txt 文件中。
@echo off
Title Kiosk Account Autologin Password Changer
::Query the registry, CHANGE the password, and report back if successful or unsuccessful
::These Kiosk accounts and passwords are pulled from the ICT SharePoint for East and West depots respectively
::Copy the "@%SystemRoot%" line and edit "User" and "Password" for each account as needed
echo Logged time = %time% %date%>> KioskPassword.txt
echo Searching for the active Kiosk account . . .
@%SystemRoot%\System32\reg.exe Query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /V "DefaultUserName" 2>NUL | %SystemRoot%\System32\findstr.exe /IRC:"^ *DefaultUserName *REG_SZ *K003566$" 1>NUL && %SystemRoot%\System32\reg.exe Add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /V "DefaultPassword" /T "REG_SZ" /D "EMj88qmjTyzy" /F 1>NUL && echo Account K003566 password change successful <======================= Active Kiosk account || echo Account K003566 password change unsuccessful
@%SystemRoot%\System32\reg.exe Query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /V "DefaultUserName" 2>NUL | %SystemRoot%\System32\findstr.exe /IRC:"^ *DefaultUserName *REG_SZ *K004167$" 1>NUL && %SystemRoot%\System32\reg.exe Add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /V "DefaultPassword" /T "REG_SZ" /D "xxn8YRryvuEK" /F 1>NUL && echo Account K004167 password change successful <======================= Active Kiosk account || echo Account K004167 password change unsuccessful
如果成功,这部分&& echo Account K003566 password change successful <======================= Active Kiosk account 是我想要记录的。我该怎么做?
【问题讨论】:
标签: batch-file logging