我正在开发一个批处理程序,该程序可以扫描 PC 的各个部分,并将它们记录到文件中。令人惊讶的是,我无法让程序创建要写入的文件。然后我尝试创建一个文件,我相当确定它会起作用;如下:
@echo off
ipconfig > ip.txt
timeout 5
但是,这也无法写入文件ip.txt
。我还尝试了以下程序,但没有成功。
@echo off
echo Test > test.txt
timeout 3
如果有人能够提供建议,我将不胜感激。
不存在错误消息,并且单击链接批处理文件
问题已解决,从Win10降级到Win7,不再遇到该问题。这不是一个很好的解决办法。
ipconfig > %userprofile%\desktop\ip.txt
使用完整路径。这将指定您的桌面作为放置文件的位置。
See Set /?
寻求帮助并输入set
查看标准变量。
& seperates commands on a line.
&& executes this command only if previous command's errorlevel is 0.
|| (not used above) executes this command only if previous command's =
errorlevel is NOT 0
> output to a file
>> append output to a file
< input from a file
| output of one command into the input of another command
^ escapes any of the above, including itself, if needed to be passed =
to a program
" parameters with spaces must be enclosed in quotes
+ used with copy to concatinate files. E.G. copy file1+file2 newfile
, used with copy to indicate missing parameters. This updates the files =
modified date. E.G. copy /b file1,,
%variablename% a inbuilt or user set environmental variable
!variablename! a user set environmental variable expanded at execution =
time, turned with SelLocal EnableDelayedExpansion command
%<number> (%1) the nth command line parameter passed to a batch file. %0 =
is the batchfile's name.
%* (%*) the entire command line.
%<a letter> or %%<a letter> (%A or %%A) the variable in a for loop. =
Single % sign at command prompt and double % sign in a batch file.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)