如何在cmd中使用当前墙纸的位置 [英] How to use the location of current wallpaper in cmd

查看:76
本文介绍了如何在cmd中使用当前墙纸的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将当前设置为墙纸的图像复制到另一个位置.我可以看到使用: REG QUERY "HKCU\Software\Microsoft\Internet Explorer\Desktop\General" /v WallpaperSource为我提供了图像位置的信息,但是如何通过管道传输并使用该位置呢?

I want to copy the image currently set as wallpaper to another location. I can see using: REG QUERY "HKCU\Software\Microsoft\Internet Explorer\Desktop\General" /v WallpaperSource provides me with the information of the image location, but how can I pipe this and use this location?

我尝试过set %foo=REG QUERY "HKCU\Software\Microsoft\Internet Explorer\Desktop\General" /v WallpaperSource要将其另存为变量.我不明白我在做什么错(我是刚接触批处理并且非常习惯于Unix).

I have tried set %foo=REG QUERY "HKCU\Software\Microsoft\Internet Explorer\Desktop\General" /v WallpaperSource To save it as a variable. I do not understand what am I doing wrong (I am new to batch and very used to unix).

我可以看到它们如何遍历输出字符串的一部分

I can see how they iterated over parts of the output string here though I am getting %%A was unexpected at this time. for:

FOR /F "usebackq skip=2 tokens=1-3" %%A IN (`REG QUERY "HKCU\Software\Microsoft\Internet Explorer\Desktop\General" /v WallpaperSource`) Do (@echo %%A : %%C)`

通常,如果我可以通过某种方式对此进行管道传输会更好,这样我就不需要使用变量了.我该怎么做?

In general it is much better if I could somehow pipe this so I will not have the need to use a variable. How do I do this?

推荐答案

以下命令行从注册表中提取数据并将其通过管道传输到Find命令中:

The following command line picks up the data from the registry and pipes it into the Find command:

For /F "EOL=H Tokens=2*" %A In ('REG QUERY "HKCU\Software\Microsoft\Internet Explorer\Desktop\General" /v WallpaperSource') Do @Echo %~B|Find ":"

只需将Find命令更改为您打算将路径传递到的任何内容.另外请注意,数据%~B可能包含空格,因此,根据要传递给其的内容的要求,使用双引号将其括起是谨慎的选择.

Just change the Find command to whatever you're intending to pipe the path to. Also be aware that the data %~B may contain spaces so it could be prudent, depending upon the requirements of whatever you are piping it to, to surround it in double quotes.

这篇关于如何在cmd中使用当前墙纸的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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