Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 使用批处理读取联机链接(.url)的url_Batch File_Url_Steam - Fatal编程技术网

Batch file 使用批处理读取联机链接(.url)的url

Batch file 使用批处理读取联机链接(.url)的url,batch-file,url,steam,Batch File,Url,Steam,到目前为止,我有以下代码(以Craft The World为例): 键入“Craft The World.url”|查找“url” 如果我在cmd中运行它,它会输出以下内容: URL=steam://rungameid/248390 网址=steam://rungameid/248390 如何将其保存到变量中?我尝试了设置A=…,但没有成功 我的目标是从中提取ID(最后6个字符),但是一旦我有了变量,我就可以在bat中使用子字符串。使用for循环来获得您想要的: for /f %%i in ('

到目前为止,我有以下代码(以Craft The World为例):

键入“Craft The World.url”|查找“url” 如果我在cmd中运行它,它会输出以下内容:

URL=steam://rungameid/248390 网址=steam://rungameid/248390 如何将其保存到变量中?我尝试了
设置A=…
,但没有成功


我的目标是从中提取ID(最后6个字符),但是一旦我有了变量,我就可以在bat中使用子字符串。

使用
for
循环来获得您想要的:

for /f %%i in ('type "Craft The World.url"^|find "URL"') do (
    set "A=%%i"
)

考虑到如果输出包含多行,您将无法在
A
中获得预期的结果。

无需使用
type
命令;使用(

for /f %%i in ('type "Craft The World.url"^|find "URL"') do (
    set "A=%%i"
)