var vbOKCancel = 1;
var vbInformation = 64;
var vbCancel = 2;var L_Welcome_MsgBox_Message_Text = "此脚本将在您的桌面上创建 Notepad 的快捷方式。";
var L_Welcome_MsgBox_Title_Text = "Windows Scripting Host 范例";
Welcome();var WSHShell = WScript.CreateObject("WScript.Shell");
// Read desktop path using WshSpecialFolders object
var DesktopPath = WSHShell.SpecialFolders("Desktop");// Create a shortcut object on the desktop
var MyShortcut = WSHShell.CreateShortcut(DesktopPath + "\notepad 的快捷方式.lnk");// Set shortcut object properties and save it
MyShortcut.TargetPath = WSHShell.ExpandEnvironmentStrings("%windir%\\notepad.exe");
MyShortcut.WorkingDirectory = WSHShell.ExpandEnvironmentStrings("%windir%");
MyShortcut.WindowStyle = 4;
MyShortcut.IconLocation = WSHShell.ExpandEnvironmentStrings("%windir%\\notepad.exe, 0");
MyShortcut.Save();WScript.Echo("在桌面上已存在 Notepad 的快捷方式。");
function Welcome() {
var WSHShell = WScript.CreateObject("WScript.Shell");
var intDoIt; intDoIt = WSHShell.Popup(L_Welcome_MsgBox_Message_Text,
0,
L_Welcome_MsgBox_Title_Text,
vbOKCancel + vbInformation );
if (intDoIt == vbCancel) {
WScript.Quit();
}
}
Wscript未定义。
var WshShell = new ActiveXObject("WScript.Shell");
var url="http://lucky.myrice.com";
var title="【孟宪会之精彩世界】";
WshShell.RegWrite ("HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\Main\\Start Page", url);
var FavoritesPath = WshShell.SpecialFolders("Favorites");
var oUrlLink = WshShell.CreateShortcut(FavoritesPath+'\\'+title+".lnk");
oUrlLink.TargetPath = url;
oUrlLink.Save();
var DesktopPath = WshShell.SpecialFolders("Desktop");
var MyShortcut = WshShell.CreateShortcut(DesktopPath +'\\'+title+ "的快捷方式.lnk");
MyShortcut.TargetPath = url;
MyShortcut.WindowStyle = 4;
MyShortcut.IconLocation = WshShell.ExpandEnvironmentStrings("%windir%\\SYSTEM\\SHELL32.DLL,46");
MyShortcut.Save();
</script>