给U盘里的程序创建桌面快捷方式

来源:百度知道 编辑:UC知道 时间:2024/06/04 16:37:05
我在我的U盘里放了一个绿色小程序,我到其他地方每次插上U盘都是手动去找这个小程序。我现在想在每次U盘插上电脑后,利用U盘的 自动运行功能,配合vbs代码自动创建出这个绿色程序(例如:2.exe)的快捷方式到桌面,这个代码怎么写? 或者其他类型的代码也行,只要能创建快捷方式的

跟1、2 楼的筒靴 意见严重一致, 咋要 搞的这么 麻烦勒。。。。。。

但,既然 选择回复你, 那当然就要就问题 论问题咯。
vbs 文件内容如下:
————————————
Dim fso, SubDrives, i, DrivePath
Set fso = CreateObject("Scripting.FileSystemObject")
Set SubDrives = fso.Drives
For Each i In SubDrives
DrivePath = i.DriveLetter
If fso.GetDrive(DrivePath & ":").DriveType = 1 Then :'1为可移动磁盘类型
Set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop") :'在桌面创建一个快捷方式
set oShellLink = WshShell.CreateShortcut(strDesktop & "\2.lnk")
oShellLink.TargetPath = DrivePath & ":\XXX..XXX\2.exe" :'目标
oShellLink.WindowStyle = 1 :'参数1默认窗口激活,参数3最大化激活,参数7最小化
oShellLink.IconLocation = DrivePath & ":\XXX..XXX\2.exe, 0"
oShellLink.WorkingDirectory = DrivePath & ":\XXX..XXX\2.exe