Create | server | shortcuts | Microsoft has given us an example of creating a shortcut, but if used directly in ASP it prompts for an error.
Examples of the original code are as follows (VBScript format):
' Windows script Host Sample Script
'
' ------------------------------------------------------------------------
' Copyright (C) 1996-1997 Microsoft Corporation
'
' You have a royalty-free right to use, modify, reproduce and distribute
' The Sample application Files (and/or any modified version) in any way
' You find useful, provided, agree, Microsoft has no warranty,
' obligations or liability for any Sample application Files.
' ------------------------------------------------------------------------
' This sample demonstrates the WshShell object to create a shortcut
' On the desktop.
L_welcome_msgbox_message_text = "This script will create a shortcut to Notepad on your desktop. "
L_welcome_msgbox_title_text = "Windows Scripting Host Example"
Call Welcome ()
' ********************************************************************************
' *
' * Shortcut related methods.
' *
Dim WshShell
Set WshShell = WScript.CreateObject ("Wscript.Shell")
Pay attention to this sentence, I do not know whether it is wrong or Microsoft can make it run, anyway, I run on the hint no object. I changed it to: Set WshShell = server. CreateObject ("Wscript.Shell")
Dim MyShortcut, MyDesktop, DesktopPath
' Read Desktop path using Wshspecialfolders object
DesktopPath = Wshshell.specialfolders ("Desktop")
' Create a shortcut object on the desktop
Set MyShortcut = wshshell.createshortcut (DesktopPath & "\notepad shortcuts. 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 "A shortcut to Notepad already exists on the desktop. "
' ********************************************************************************
' *
' * Welcome
' *
Sub Welcome ()
Dim Intdoit
Intdoit = MsgBox (L_welcome_msgbox_message_text, _
vbOKCancel + vbinformation, _
L_welcome_msgbox_title_text)
If Intdoit = vbcancel Then
Wscript.Quit
End If
End Sub
The following is my transformation after the use of the ASP.
<%l_welcome_msgbox_message_text = "This script will create a shortcut to Notepad on your desktop. "
L_welcome_msgbox_title_text = "Windows Scripting Host Example"
Response.Write L_welcome_msgbox_message_text
Dim WshShell
Set WshShell = server. CreateObject ("Wscript.Shell")
Dim MyShortcut, MyDesktop, DesktopPath
DesktopPath = Wshshell.specialfolders ("Desktop")
Set MyShortcut = wshshell.createshortcut (DesktopPath & "\notepad shortcuts. lnk")
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
Response.Write <BR> Shortcuts created! "
%>
has been tested on my NT4 pass.