适用于所有 Windows 版本的所有用户桌面路径的环境变量是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6038580/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 08:23:27  来源:igfitidea点击:

What is the environment variable for the All Users Desktop path that works across all versions of Windows?

windowsbatch-fileenvironment-variables

提问by Chaddeus

I'm trying to write a batch file that can copy a file from my computer to all computers in a list. It needs to be copied to the AllUsers Desktop (I'll use a domain admin account to run the batch file).

我正在尝试编写一个批处理文件,该文件可以将文件从我的计算机复制到列表中的所有计算机。它需要复制到 AllUsers 桌面(我将使用域管理员帐户来运行批处理文件)。

On my Win7 system, the %ALLUSERSPROFILE%returns C:\ProgramData. Is there a variable that returns the AllUsers Desktop path across every version of Windows? I have a mix of XP, Vista, and Win7.

在我的 Win7 系统上,%ALLUSERSPROFILE%返回 C:\ProgramData。是否有一个变量可以返回每个 Windows 版本的 AllUsers 桌面路径?我有 XP、Vista 和 Win7 的组合。

采纳答案by CharlesB

There's no environment variable holding desktop path, but with this postyou can see how to get it in batch (answers are for current user desktop, you'll need to adapt them for all users desktop

没有保存桌面路径的环境变量,但是通过这篇文章,您可以看到如何批量获取它(答案针对当前用户桌面,您需要针对所有用户桌面进行调整

回答by Kyle P

It is %public%in Windows 7...

%public%在 Windows 7...

回答by user3887965

in vista, 7, 8

在远景, 7, 8

%userprofile%\..\Default\Desktop

%userprofile%\..\Default\Desktop

回答by Robert Tozzi

%public% works for Windows 10 and Windows 2011 Server and up

%public% 适用于 Windows 10 和 Windows 2011 Server 及更高版本

%ALLUSERSPROFILE% is used in Windows XP

%ALLUSERSPROFILE% 用于 Windows XP

But, you can look to see what the available variables are by running "SET" from a command prompt

但是,您可以通过从命令提示符运行“SET”来查看可用变量是什么