通过WSH CreateShortcut 在桌面创建快捷方式

上一篇 / 下一篇  2013-05-29 14:57:34 / 个人分类:QTP

域名

CreateShortcut 方法

作用:创建一个对象引用,指向一个快捷方式或 URLshortcut

语法格式:object.CreateShortcut(strPathname)

参数说明:

1。object:WScript. 对象。

2. strPathname:被创建的快捷方式的路径与文件名。

说明: 一个 Windows 快捷方式必须有扩展名 “.lnk”。 如果快捷方式标题以 “.url” 结束,则创建一个WshURLShortcut对象。

脚本举例:

set wshshell=CreateObject("WScript.Shell")
desktoppath=wshshell.SpecialFolders("desktop")'SpecialFolders:获取任意一个WINDOWS特殊文件夹的信息
set shortcut1=wshshell.CreateShortcut(desktoppath+"\\记事本快捷方式.lnk")  '在桌面创建一个名为“记事本快捷方式”的快捷方式(即:记事本快捷方式.lnk文件)
shortcut1.targetpath="c:\\windows\\notepad.exe"  '将这个快捷方式的目标指向notepad.exe
shortcut1.save()


TAG: CreateShortcut WSH 对象

 

评分:0

我来说两句

Open Toolbar