在 Windows 批处理脚本中追加 [英] Appending in a Windows Batch Script

查看:45
本文介绍了在 Windows 批处理脚本中追加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在计算机上编写所有程序,并将这些程序名称附加到programs.txt"文件中的文本中.现在,代码正在删除当前文本并将程序名称放入文本文件中.我希望它附加程序名称,因此如果有人知道如何调整以下代码以附加,我将不胜感激.

I'm trying to write all the programs on a computer, and APPEND those programs names to the text in the 'programs.txt' file. Right now, the code is deleting the current text and putting the program names in the text file. I would like it to append the program names, so if anyone knows how to adjust the below code to append, I'd appreciate the info.

wmic /output:C:\Users\Jerry\Desktop\programs.txt product get name,version

推荐答案

试试这个:

wmic product get name,version >>"C:\Users\Jerry\Desktop\programs.txt"

更好的解决方案是分两步完成(由于 WMIC 的 Unicode 输出):

A better solution will be to do it in 2 steps (cause of the Unicode output of WMIC) :

wmic /output:C:\Users\Jerry\Desktop\temp.txt product get name,version
type "C:\Users\Jerry\Desktop\temp.txt">>"C:\Users\Jerry\Desktop\programs.txt"

这篇关于在 Windows 批处理脚本中追加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆