新手批量发出─创建文件 [英] Novice Batch Issue- Creating Files

查看:129
本文介绍了新手批量发出─创建文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个批处理程序将扫描PC的各个部分,并把它们记录到文件中。出人意料的是,我无法让程序创建写入文件。然后我试图创建一个文件,我是相当肯定会的工作;它是如下:

 关闭@echo
IPCONFIG> ip.txt
超时5

然而,这也无法写入文件 ip.txt 。我也试图下面的程序,但没有成功。

 关闭@echo
回声试验>的test.txt
超时3

如果任何人都能够提出建议,我更AP preciate它。

没有错误消息是present,并点击链接批处理文件

解决的问题,从Win10降级到Win7和不再遇到的问题。不是一个伟大的补丁。


解决方案

  IPCONFIG> %USERPROFILE%\\桌面\\ ip.txt

使用完整路径。这指定您的桌面放文件的位置。

请参阅设置/?寻求帮助,键入设置来看看标准变量。


 &安培;方式隔开一行命令。&功放;&安培;执行仅previous命令的错误级别为0这个命令。|| (以上未使用)执行此命令只有previous命令的=
错误级别不为0>输出到文件>>追加输出到文件<从文件输入|一个命令的输出到另一个命令的输入^逸出任何上述,包括本身,如果需要的话将被传递的=
一个节目带空格的参数必须用引号括起来+与副本用于concatinate文件。例如。复制文件1 +文件2的newfile,用于复制指示缺少的参数。这将更新文件=
修改日期。例如。复制/ B文件1 ,,%VARIABLENAME%一个内置的或用户​​设置环境变量!变量名!用户设置环境变量扩展在执行=
时间,竟然有SelLocal EnableDelayedExpansion命令%LT;数> (%1)传递给一个批处理文件的第n个命令行参数。 %0 =
是批处理文件的名字。%*(*%)整个命令行。%LT;一个字母GT;或%%<一个字母GT; (%A或%% A)在for循环中的变量。 =
在一个批处理文件命令提示符,然后双击%符号单%符号。

I was working on developing a batch program that would scan various sections of a PC, and log them to a file. Surprisingly, I was unable to have the program create the file to write to. I then tried to create a file, that I was fairly certain would work; it is as followed:

@echo off
ipconfig > ip.txt
timeout 5

However, this was also unable to write to the file ip.txt. I also attempted the following program, with no success.

@echo off
echo Test > test.txt
timeout 3

If anyone would be able to give advice, I would much appreciate it.

No error messages are present, and clicking the link batch file

Issue Resolved, downgraded to Win7 from Win10 and no longer experiencing the issue. Not a great fix.

解决方案

ipconfig > %userprofile%\desktop\ip.txt

Use full paths. This specifies your desktop as the place to put the file.

See Set /? for help and type set to see standard variables.


&    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.

这篇关于新手批量发出─创建文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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