|
kidzgy
中级用户
  
积分 262
发帖 129
注册 2007-7-11
状态 离线
|
『楼 主』:
[已完结]帮我修正一下快捷方式打开所在位置的VBS代码
使用 LLM 解释/回答一下
set args = WScript.Arguments
linkname = args(0)
set wshshell = CreateObject("WScript.Shell")
set scut = wshshell.CreateShortcut(linkname)
set fs = CreateObject("Scripting.FileSystemObject")
folder = """" & fs.GetParentFolderName(scut.TargetPath) & """"
wshshell.Run(folder)
这一段是VBS代码。里面有个BUG。附件是安装卸载的BAT.其中包括了VBS代码。
这是一个给快捷方式添加右键【打开所在位置】的程序,功能是右键点击以后打开快捷方式的相应目录。
功能类似于右键属性-查找目标,但是不同的是可以不用查看属性,而且查找目标是选定目标,而打开所在位置是直接打开快捷方式的对应文件夹没有选定目标。
我提出来的问题是,这个VBS运行起来有个BUG,其实这个VBS在网上广为流传,无意中发现便希望兄弟们解决一下问题修复下BUG,完善程序。
例如说:我在桌面上有个maxthon的快捷方式,对应程序是E:\Maxthon\Maxthon.exe
如果同时拥有程序E:\Maxthon.exe (即在E盘存在文件maxthon.exe)
那么在maxthon右键打开所在位置的时候,是在运行E:\Maxthon.exe,当然了,如果没有E:\Maxthon.exe是能实现功能的,这就是BUG。
希望各位能修复一下,就算存在文件E:\Maxthon.exe也能照常进入到快捷方式的对应文件夹。
Last edited by kidzgy on 2009-8-7 at 08:56 ]
set args = WScript.Arguments
linkname = args(0)
set wshshell = CreateObject("WScript.Shell")
set scut = wshshell.CreateShortcut(linkname)
set fs = CreateObject("Scripting.FileSystemObject")
folder = """" & fs.GetParentFolderName(scut.TargetPath) & """"
wshshell.Run(folder)
This is a VBScript code. There is a BUG in it. The attached file is the installation and uninstallation BAT, which includes the VBScript code.
This is a program to add the right-click "Open containing folder" to a shortcut. The function is to open the corresponding directory of the shortcut when right-clicking.
It is similar to Right-click Properties - Find Target, but the difference is that you don't need to view the properties, and Find Target selects the target, while Open containing folder directly opens the corresponding folder of the shortcut without selecting the target.
The problem I raised is that there is a BUG when this VBS runs. In fact, this VBS is widely spread on the Internet. I accidentally discovered it and hope brothers can solve the problem and fix the BUG to improve the program.
For example: I have a Maxthon shortcut on the desktop, and the corresponding program is E:\Maxthon\Maxthon.exe
If there is also the program E:\Maxthon.exe (that is, the file maxthon.exe exists in the E drive)
Then when right-clicking the maxthon to open the containing folder, it is running E:\Maxthon.exe. Of course, if there is no E:\Maxthon.exe, the function can be realized. This is the BUG.
Hope everyone can fix it, so that even if the file E:\Maxthon.exe exists, it can still enter the corresponding folder of the shortcut normally.
Last edited by kidzgy on 2009-8-7 at 08:56 ]
附件
1: 打开所在位置插件.rar (2009-7-29 05:32, 1.25 KiB,下载次数: 11)
|
|
2009-7-29 05:32 |
|
|
tireless
银牌会员
    
积分 2025
发帖 1122
注册 2007-9-5
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
另一个代码:
(出处: http://bbs.360safe.com/viewthread.php?tid=99058&page=1#pid352070)
dim ws,objArgs,strPath
Set objArgs = WScript.Arguments
if objArgs.Count>0 then
strPath=mid(objArgs(0),instr(objArgs(0),"/")+1,len(objArgs(0))-instr(objArgs(0),"/"))
end if
set ws=CreateObject("Wscript.Shell")
ws.run "Explorer /select, " & GetTargetPath(strPath)
Function GetTargetPath(LinkName)
On Error Resume Next
Dim Shortcut
Set Shortcut = CreateObject("Wscript.Shell").CreateShortcut(LinkName)
GetTargetPath = Shortcut.TargetPath
Shortcut.Save
Set Shortcut = Nothing
End Function
Another code:
(Source: http://bbs.360safe.com/viewthread.php?tid=99058&page=1#pid352070)
dim ws,objArgs,strPath
Set objArgs = WScript.Arguments
if objArgs.Count>0 then
strPath=mid(objArgs(0),instr(objArgs(0),"/")+1,len(objArgs(0))-instr(objArgs(0),"/"))
end if
set ws=CreateObject("Wscript.Shell")
ws.run "Explorer /select, " & GetTargetPath(strPath)
Function GetTargetPath(LinkName)
On Error Resume Next
Dim Shortcut
Set Shortcut = CreateObject("Wscript.Shell").CreateShortcut(LinkName)
GetTargetPath = Shortcut.TargetPath
Shortcut.Save
Set Shortcut = Nothing
End Function
|
|
2009-7-29 12:29 |
|
|
kidzgy
中级用户
  
积分 262
发帖 129
注册 2007-7-11
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
非常感谢你的代码,你那功能就完全等于查找目标的了。
而我需要的是,打开快捷方式所在路径,而不选择目标,就是好像鼠标单击了一下那样。查找目标是有的,我想要的是没有的,并且最好能最大化窗口。
Thank you very much for your code. Your function is exactly equivalent to finding the target.
And what I need is to open the path where the shortcut is located without selecting the target, just like clicking the mouse once. There is the "Find Target", what I want is not, and it is best to maximize the window.
|
|
2009-7-29 20:36 |
|
|
slore
铂金会员
      
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
汗~
结合下。。。
wshshell.Run(folder)
改为
wshshell.Run("explorer " & folder)
Sweat~
Combine below...
wshshell.Run(folder)
changed to
wshshell.Run("explorer " & folder)
|

S smile 微笑,L love 爱,O optimism 乐观,R relax 放松,E enthusiasm 热情...Slore |
|
2009-7-31 07:11 |
|
|
kidzgy
中级用户
  
积分 262
发帖 129
注册 2007-7-11
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
哇,不会吧,就这么简单了。
太感谢啦。那新的代码就是
set args = WScript.Arguments
linkname = args(0)
set wshshell = CreateObject("WScript.Shell")
set scut = wshshell.CreateShortcut(linkname)
set fs = CreateObject("Scripting.FileSystemObject")
folder = """" & fs.GetParentFolderName(scut.TargetPath) & """"
wshshell.Run("explorer " & folder)
Wow, no way, it's that simple.
Thanks a lot. Then the new code is
set args = WScript.Arguments
linkname = args(0)
set wshshell = CreateObject("WScript.Shell")
set scut = wshshell.CreateShortcut(linkname)
set fs = CreateObject("Scripting.FileSystemObject")
folder = """" & fs.GetParentFolderName(scut.TargetPath) & """"
wshshell.Run("explorer " & folder)
|
|
2009-7-31 08:55 |
|
|
slore
铂金会员
      
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
不知道不选中有啥好处。。。
I don't know what benefits there are if it's not selected...
|

S smile 微笑,L love 爱,O optimism 乐观,R relax 放松,E enthusiasm 热情...Slore |
|
2009-7-31 09:09 |
|
|
kidzgy
中级用户
  
积分 262
发帖 129
注册 2007-7-11
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
是这样的,如果文件夹文件非常多,选中的话,就会到那个文件,可是滚动轴却不在最上端。
如果不选中,就好像双击文件夹刚进入一样,更加快速浏览了。
It's like this. If there are a lot of files in a folder and you select one, it will go to that file, but the scroll bar is not at the top. If you don't select, it's like double-clicking the folder and just entering, which is a faster way to browse.
|
|
2009-8-1 07:58 |
|
|
kidzgy
中级用户
  
积分 262
发帖 129
注册 2007-7-11
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
对了,又有新问题出现了,当快捷方式属性【目标】【起始位置】开头和末尾有" 双引号的时候,就没法打开所在位置了。
这样的话又该怎么样解决呢
By the way, a new problem has emerged. When there are double quotes at the beginning and end of the "Target" and "Start in" properties of the shortcut, the location cannot be opened. Then, how should this be solved?
|
|
2009-8-4 08:39 |
|
|
slore
铂金会员
      
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
folder = """" & fs.GetParentFolderName(scut.TargetPath) & """"
因为你又加了一次……
先判断本身有引号没。。。
没有再加
folder = """" & fs.GetParentFolderName(scut.TargetPath) & """"
Because you added it again...
First, check if there are quotes already. If not, add them
|

S smile 微笑,L love 爱,O optimism 乐观,R relax 放松,E enthusiasm 热情...Slore |
|
2009-8-4 09:37 |
|
|
kidzgy
中级用户
  
积分 262
发帖 129
注册 2007-7-11
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
用5楼修改好的代码就弹出这样的提示。
那该怎么样改呢?
Last edited by kidzgy on 2009-8-6 at 08:18 ]
The code modified by floor 5 pops up such a prompt. Then how to modify it?
Last edited by kidzgy on 2009-8-6 at 08:18 ]
|
|
2009-8-4 21:15 |
|
|
kidzgy
中级用户
  
积分 262
发帖 129
注册 2007-7-11
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
我试着按你所说,首末都减去一个双引号,或是2个,都没有效果,还是这样的提示
I tried to subtract one double quote or two from both the beginning and the end as you said, but it didn't work, and there's still such a prompt.
|
|
2009-8-4 21:16 |
|
|
slore
铂金会员
      
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
wshshell.Run(folder)
前
msgbox folder你就知道你改的有问题了
wshshell.Run(folder)
Before
msgbox folder you'll know your modification is wrong
|

S smile 微笑,L love 爱,O optimism 乐观,R relax 放松,E enthusiasm 热情...Slore |
|
2009-8-5 01:39 |
|
|
kidzgy
中级用户
  
积分 262
发帖 129
注册 2007-7-11
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
我增补了msgbox folder后,对着没有双引号的运行,就弹出首末有双引号。
可是,对着有首末双引号的运行,还是10楼的提示,原因是不是以lnk或url末尾结尾的。
由此可见,问题是,怎么使VBS支持有双引号的快捷方式。
Last edited by kidzgy on 2009-8-6 at 08:20 ]
After I added the msgbox folder, running without double quotes pops up with double quotes at the beginning and end.
But running with double quotes at the beginning and end is still the prompt from post 10. The reason might be ending with.lnk or.url.
Thus, the problem is how to make VBS support shortcuts with double quotes.
Last edited by kidzgy on 2009-8-6 at 08:20 ]
|
|
2009-8-5 05:46 |
|
|
slore
铂金会员
      
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
『第 14 楼』:
使用 LLM 解释/回答一下
有引号的就不要再加引号了……
Don't add quotation marks to the ones that already have quotation marks...
|

S smile 微笑,L love 爱,O optimism 乐观,R relax 放松,E enthusiasm 热情...Slore |
|
2009-8-5 07:45 |
|
|
kidzgy
中级用户
  
积分 262
发帖 129
注册 2007-7-11
状态 离线
|
『第 15 楼』:
使用 LLM 解释/回答一下
麻烦你按照5楼的代码,修正一下,贴个完整的好吗?因为我是新手,如果你贴出个修正好的完全代码,我仔细比对一下,或许我更能理解哪里出了问题,这样我也会成长得更快吧
Please provide the content that needs to be translated, including the Chinese text and any relevant code blocks if applicable. Currently, the input only has the Chinese request without the specific code or content from the 5th floor that needs to be translated. Please provide the full relevant content for translation.
|
|
2009-8-5 08:19 |
|