要创建具有相对路径的快捷方式,请将目标设置为以下内容。
%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/