2017-06-29 64 views
0

这是登录脚本的一部分。脚本每次用户登录到他们的计算机时都会运行。脚本需要做的事情是每次运行时都登录到同一个文件,但我不希望它覆盖数据。我希望它添加到下面的行。我很难找出它,这是我迄今为止所有:在批中追加数据

if not exist "C:\Windows\LogonScript" mkdir C:\Windows\LogonScript" 
(echo Username: %USERNAME% 
systeminfo | findstr /c:"Host Name" 
systeminfo | findstr /c:"Domain" 
systeminfo | findstr /c:"OS Name" 
systeminfo | findstr /c:"System Manufacturer" 
systeminfo | findstr /c:"System Model" 
systeminfo | findstr /c:"System type" 
systeminfo | findstr /c:"Total Physical Memory" 
ipconfig | findstr IPv4 
echo Hard Drive Information: 
wmic LOGICALDISK where drivetype=3 get caption,size,FreeSpace) > C:\Windows\LogonScript\%COMPUTERNAME%.txt 

xcopy /s C:\Windows\LogonScript\%COMPUTERNAME%.txt \\ess\Home\cgoodwin\Scripts 

exit 
+2

变化')> C:\ WINDOWS \ LogonScript \%COMPUTERNAME%.txt'到') >> “C:\ WINDOWS \ LogonScript \%COMPUTERNAME%.TXT”' – Compo

回答

1

以下代码片段将使用我在我的评论中给出的答案附加。此外,它应该是相当快,(由刚刚运行很慢的系统的系统命令的单个实例)

If Not Exist "C:\Windows\LogonScript\" MD "C:\Windows\LogonScript" 
(Echo UserName:     %UserName% 
SystemInfo|FindStr/IL /C:"Host Name:" /C:"Domain:" /C:"OS Name:"^ 
/C:"System Manufacturer:" /C:"System Model:" /C:"System Type:"^ 
/C:"Total Physical Memory:" 
For /F "Tokens=2 Delims=:" %%A In ('IPConfig^|Find "IPv4"' 
) Do Echo=IP Address:    %%A 
Echo(
Echo Logical Disk Information: 
WMIC LogicalDisk Where DriveType=3 Get Caption, Size, FreeSpace|More 
)>>"C:\Windows\LogonScript\%ComputerName%.txt"