可以使用Windows中的快捷方式为应用程序设置环境变量吗? [英] Can I set an environment variable for an application using a shortcut in Windows?

查看:661
本文介绍了可以使用Windows中的快捷方式为应用程序设置环境变量吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一种感觉,我应该可以添加一个目录到 PATH 环境变量在应用程序生命周期的基础上,但我无法找到如何做到这一点。可以向Windows快捷方式添加一个参数,将目录附加到当前PATH值,供应用链接使用。

I have a feeling I should be able add a directory to the PATH environment variable on an application-lifetime basis, but I can't find out how to do this. Is it possible to add a parameter to a Windows shortcut that appends a directory to the current value of PATH for use by the application being linked?

推荐答案

让快捷方式执行批处理文件(.cmd),

Let the shortcut execute a batch file (.cmd), that


  • 设置环境变量

  • 执行应用程序

  • 您可以使用START执行应用程序,这将在另一个进程中启动应用程序,但会复制环境。您不等待该应用完成。

  • 现在您可以退出批处理文件。

  • Sets the environment variable
  • execute the app
  • You use "START" to execute the app, this will start the app in another process, but it will copy the environment. You do not wait for the app to finish.
  • Now you can exit the batch file.

应该如下所示:

@echo off
set path=%path%;C:\My Folder
start "Path to my exe"

这篇关于可以使用Windows中的快捷方式为应用程序设置环境变量吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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