如何为可执行文件创建链接并以批处理或VBS方式指示工作文件夹? [英] How to create link for executable file and indicate work folder in batch or VBS?

查看:122
本文介绍了如何为可执行文件创建链接并以批处理或VBS方式指示工作文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

操作系统:Windows 7

OS: Windows 7

我正在尝试通过这样的批处理创建指向桌面文件夹的链接:

I am trying to create a link to the desktop folder via batch like this:

mklink "%userprofile%\Desktop\MyExe" "%~dp0\MyExe.exe" 

该命令有效,但是如何指示MyExe.exe"%~dp0"执行? MyExe.exe看起来像在当前文件夹中运行,因此无法加载我的配置文件.

The command worked, but how to indicate MyExe.exe execute at "%~dp0"? MyExe.exe looks like run at the current folder, so it can't load my config file.

更新:

使用VBS解决了不同的问题,下面的运行代码将创建一个快捷方式 C:\Users\jiu\Desktop\MyExe.exe,但我想要MyExe.exe.

Got the different problem by using VBS, run code in below will create a shortcut for C:\Users\jiu\Desktop\MyExe.exe, But I want MyExe.exe.

Set oWS = WScript.CreateObject("WScript.Shell")
userProfilePath = oWS.ExpandEnvironmentStrings("%UserProfile%")
currParentFolder = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName)
linkPath = userProfilePath + "\Desktop\MyExe.LNK"
Set oLink = oWS.CreateShortcut(linkPath)
    oLink.TargetPath = "MyExe.exe" 
    oLink.WorkingDirectory = currParentFolder
oLink.Save

推荐答案

根据您提供的信息,这是一个看起来很奇怪的批处理文件,应为您创建桌面快捷方式:

Based upon the information you have provided, here's a strange looking batch file which should create your desktop shortcut for you:

;@Rundll32 AdvPack.dll,LaunchINFSection "%~0",,1
;@GoTo :EOF
[Version]
Signature="$Windows NT$"
[DefaultInstall]
ProfileItems=AddLnk
[AddLnk]
Name="MyExe",8,16
CmdLine=1,,"MyExe.exe"
InfoTip="Execute MyExe.exe"
WorkingDir=1

您可以选择修改:

  • 快捷方式通过替换行8上双引号内的字符串来显示名称
    .
  • 目标可执行文件的名称
    ,通过替换行9上双引号内的字符串.
  • 快捷方式描述注释
    ,方法是替换行10上双引号内的字符串.
  • The shortcuts display name
    by replacing the string inside the doublequotes on line 8.
  • The name of the target executable
    by replacing the string inside the doublequotes on line 9.
  • The shortcuts description comment
    by replacing the string inside the doublequotes on line 10.

这篇关于如何为可执行文件创建链接并以批处理或VBS方式指示工作文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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