在目录名的脚本中使用通配符

发布于 2024-10-05 01:46:58 字数 372 浏览 0 评论 0原文

我正在编写一个脚本,其中我想将文件从我的目录复制到计算机中的“开始菜单\程序\启动”。 我的问题是 - 该脚本适用于多台计算机,并且由于某种原因,每台计算机的管理员都有不同的名称,因此路径“C:\Documents and Settings*administrator*\Start Menu\Programs\创业”并不适合所有人。

我正在寻找一种在目录名称中使用通配符的方法。像这样的东西: “C:\Documents and Settings\administrator*\Start Menu\Programs\Startup”,所以我的脚本将在所有计算机上运行。 (该名称预先未知,但我确实知道它将以“管理员”一词开头)

有什么想法吗? 谢谢,

塔玛

I'm writing a script in which i want to copy a file from my directory to the "Start Menu\Programs\Startup" in the computer.
My problem is - this script is for several computers and from some reason in each one the administrator has a different name,so the path "C:\Documents and Settings*administrator*\Start Menu\Programs\Startup" is not suitable for all.

I'm looking for a way to use a wild card in the directory name . something like:
"C:\Documents and Settings\administrator*\Start Menu\Programs\Startup", so my script will work in all computers. (the name is unknown from advance but i do know that it will start with the word 'administrator')

Any ideas?
Thanks,

Tamar

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

难以启齿的温柔 2024-10-12 01:46:58

可能有更聪明的方法,但一种方法是使用 for 命令。像下面这样:

cd "c:\documents and settings"
for /D %%f in (administrator*) do copy yourfile "%%f\start menu\programs\startup"

There are probably more clever ways, but one way would be to use the for command. Something like the following:

cd "c:\documents and settings"
for /D %%f in (administrator*) do copy yourfile "%%f\start menu\programs\startup"
隔纱相望 2024-10-12 01:46:58

也许该变量

%userprofile%

对您有用。它直接为您提供路径“C:\Documents and Settings\CurrentLoggedUser”。

May be the variable

%userprofile%

could be useful for you. It gives you directly the path "C:\Documents and Settings\CurrentLoggedUser".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文