[英]How do I write text and timestamps to a file from a batch file?
I want to write an interactive Windows script that takes a users name and username and saves it to a file for user records that notes their information and the time they entered it. 我想编写一个交互式Windows脚本,该脚本获取用户名和用户名,并将其保存到用户记录的文件中,以记录他们的信息和输入的时间。 Can anyone teach me how I would go about this.
任何人都可以教我如何做到这一点。
@echo off
ECHO Welcome to the User Records System
SET /P <name>=[Please enter you full name.]
SET /P <uName>=[Please enter your username.]
ECHO %name%
ECHO %uName%
I'm writing this in notepad++ because I assumed it would make my life easier. 我用记事本++写这个,因为我认为它会让我的生活更轻松。
Any input would be greatly appreciated. 任何投入将不胜感激。
You can use the %time%
variable for the time, and >>
to append to a file. 您可以使用
%time%
变量作为时间, >>
可以附加到文件。
@echo off
ECHO Welcome to the User Records System
SET /P <name>=[Please enter you full name.]
SET /P <uName>=[Please enter your username.]
ECHO %name% >>C:\details.txt
ECHO %uName% >>C:\details.txt
ECHO %time% >>C:\details.txt
Modify however you wish! 根据您的意愿修改!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.