windows - 是否可以在以管理员身份运行的 Windows 中创建相对路径的快捷方式?

标签 windows relative-path uac shortcut

要创建具有相对路径的快捷方式,请将目标设置为以下内容。

%windir%\system32\cmd.exe /c start your_relpath\app.exe [your_args]

让程序以管理员身份运行也很简单。

Properties > Advanced > Run as administrator

但是将两者放在一起是行不通的。当 cmd.exe 以管理员身份启动时,它会丢失当前工作目录并转到 %windir%\system32。相对路径从那里开始,这不是预期的。

有什么方法可以创建一个相对又以管理员身份运行的快捷方式?

最佳答案

我没有找到简单的方法,但没关系。我担心具有绝对路径的快捷方式会在计算机之间中断。我没有意识到 Windows 会自动更正它们。这似乎足够了,尽管相对路径会更优雅。

Although shortcuts, when created, point to specific files or folders, they may break if the target is moved to another location. Microsoft Windows has standard algorithms for fixing up shortcuts when they are moved. Windows 9x-based versions of Windows use a simple search algorithm to fix broken shortcuts.[1] On Windows NT-based operating systems and the NTFS file system, the target object's unique identifier is stored in the shortcut file and Windows can use the Distributed Link Tracking service for tracking the targets of shortcuts, so that the shortcut may be silently updated if the target moves to another hard drive.[4]

http://en.wikipedia.org/wiki/File_shortcut#Microsoft_Windows

关于windows - 是否可以在以管理员身份运行的 Windows 中创建相对路径的快捷方式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18756671/

相关文章:

.net - 在域网络中激活UAC的情况下,从用户启动的过程以域管理员身份启动过程

c++ - 带有两个 dwDesiredAccess 的 OpenProcess 函数

java - jwrapper online Windows 因 https updateurl 失败

windows - 如何以非管理员身份在 Windows 7 上安装 yarn?

javascript - PHP 包含包含相对路径的 html 文件

windows - 当路径没有目录分隔符时会发生什么?

windows - 如何从不同的线程执行 SendMessage?

asp.net - 为什么 ASP.Net 重写 runat=server anchor 控件的相对路径?

windows - ActiveX 无法在没有特权提升的情况下运行 .exe

windows-7 - 在网络服务帐户下发布到 WMI 时出现权限问题