|  | 
8#
 
 
 楼主|
发表于 2018-7-28 12:37:34
|
只看该作者 
| 本帖最后由 765058729 于 2018-7-28 12:41 编辑 
 
 好像是只要有附到开始菜单的动作,注册表就会有改动,我也不是很懂,不过我根据你辛苦劳动得来的代码改动一下成功,多谢,我自己真的是一窍不能,摸索着玩
 
 我估摸着它的原理是先在附件的文件夹创建一个快捷方式,然后再检索这个快捷方式的右键菜单,只要有"附到"这两个字就点击,用下面的代码可以
 
 
 Set WshShell=WScript.CreateObject("WScript.Shell")
 Set objShell = CreateObject("Shell.Application")
 Set objFSO = CreateObject("Scripting.FileSystemObject")
 lnkfile="%userprofile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories\" '指定存放位置
 
 lnkfile=WshShell.ExpandEnvironmentStrings(lnkfile) '解析环境变量,还原成真实路径
 Shortcut "附到开始菜单测试","C:\Program Files\Internet Explorer\iexplore.exe" '建立快捷方式的名字和路径文件
 Set objShell = CreateObject("Shell.Application")
 path=Left(lnkfile,InStrRev(lnkfile,"\"))
 Set objFolder = objShell.Namespace(path)
 name=Replace(lnkfile,path,"")
 Set objFolderItem = objFolder.ParseName(name)
 Set colVerbs = objFolderItem.Verbs
 For Each objVerb in colVerbs
 If Left(objVerb.name,2) = "附到" Then objVerb.DoIt
 Next
 
 
 
 Function Shortcut(Short_name,path_and_name) '为菜单创建一个快捷方式
 lnkfile=lnkfile & "" & Short_name & ".lnk"    '名称
 set oShellLink = WshShell.CreateShortcut(lnkfile)
 oShellLink.TargetPath = path_and_name      '目标
 oShellLink.WindowStyle = 1    '窗口样式  1默认窗口激活,参数3最大化激活,参数7最小化
 oShellLink.Hotkey = ""         '快捷键
 oShellLink.IconLocation = path_and_name & ",0"     '第几个图标
 oShellLink.Description = Short_name      '备注
 oShellLink.WorkingDirectory = left(path_and_name,InStrRev(path_and_name,"")-1)   '起始位置
 oShellLink.Arguments = ""    '参数
 oShellLink.Save     '保存
 End Function
 | 
 |