求一个批处理文件,实现自动创建某个程序的快捷方式

2024-11-17 11:54:56
推荐回答(2个)
回答(1):

@echo off
echo Dim WshShell,Shortcut>%temp%\a.vbs
echo Dim path,fso>>%temp%\a.vbs
echo path="%cd%\B.exe">>%temp%\a.vbs
echo Set fso=CreateObject^("Scripting.FileSystemObject"^)>>%temp%\a.vbs
echo Set WshShell=WScript.CreateObject^("WScript.Shell"^)>>%temp%\a.vbs
echo Set Shortcut=WshShell.CreateShortCut^("%userprofile%\桌面\C.lnk"^)>>%temp%\a.vbs
echo Shortcut.TargetPath=path>>%temp%\a.vbs
echo Shortcut.Save>>%temp%\a.vbs
start "%SystemRoot%\System32\WScript.exe" "%temp%\a.vbs"

%cd%的意思就是当前目录,不管在哪都有效

那就用这个:

@echo off
set pa=%userprofile%\桌面\C.url
echo ^[InternetShortcut^]>"%pa%"
echo URL=file:\\%cd%\B.exe>>"%pa%"
echo Modified=705EC2AA0B10CA0120>>"%pa%"
echo IconIndex=0 >>"%pa%"
echo IconFile=%cd%\B.exe>>"%pa%"

个人能力有限...

回答(2):

有错误,改一改

Dim WshShell,Shortcut
Dim path,fso
Set fso=CreateObject("Scripting.FileSystemObject")
Set WshShell=WScript.CreateObject("WScript.Shell")
path=WshShell.CurrentDirectory +"\B.exe"
Set Shortcut=WshShell.CreateShortCut("C:\Documents and Settings\wf\桌面\C.lnk" )
Shortcut.TargetPath=path
Shortcut.Save