Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem is refresh!
Message
De
01/02/2001 01:46:49
 
 
À
01/02/2001 01:31:42
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00465054
Message ID:
00471115
Vues:
46
>Dear Martin,
>
>Thanks for sending reply.
>
>Your WSH code is working. I am able to create shortcut. But my application HPGAS.exe gets installed in hPGAS directory by default. If some one changes the name of the target directory, then this shortcut will be created, but will not work .
>My question is how to sense the current directory as working directory. (I do not want to hardcode target directory name as shown in the following code).
>

The simplest way is to fire the application and have it check to see if the shortcut already exists on the desktop; if not, have it create the shortcut based on where it's located:
oShell = CREATEOBJ('Wscript.Shell')
cDesktop = oShell.SpecialFolders('Desktop')
IF ! FILE(ADDBS(cDesktop)+'HPGAS.LNK')
   *  Shortcut doesn't exist
   cMyEXELoc = FULLPATH(SYS(16,0))
   cMyCurrentDir = FULLPATH(CURDIR())
   *  So go create the shortcut using the CreateShortcut method - you
   *  know where the desktop is, where the app was started, and where the 
   *  executable resides.  You can use the default icon for the executable
ENDIF
>
>I have used following code
>
>
>
>L_Welcome_MsgBox_Message_Text   = "This script will create a shortcut to HPGAS on your desktop."
>L_Welcome_MsgBox_Title_Text     = "Windows Scripting Host Sample"
>Call Welcome()
>
>
>Dim WSHShell
>Set WSHShell = WScript.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 & "\HPGAS.lnk")
>
>' Set shortcut object properties and save it
>MyShortcut.TargetPath = "\HPGAS\hpgas.exe"
>MyShortcut.WorkingDirectory = "\HPGAS"
>MyShortcut.WindowStyle = 3
>MyShortcut.IconLocation = "\HPGAS\hpgas.exe,0"
>MyShortcut.Save
>
>
>
>
>
>WScript.Echo "A shortcut to HPGAS now exists on your 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
>
>
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform