How to create a shortcut to my HTA ?

Batch, ASP, JScript, Kixtart, etc.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
hackoo
Posts: 103
Joined: Sat Jan 22, 2011 12:27 am

How to create a shortcut to my HTA ?

Post by hackoo » Tue Mar 15, 2011 1:34 am

Hi !I wonder if this is possible to create a shortcut to my HTA coded on same HTA ?The Problem is how can i get the full Name and the full path of my HTA that i can put it on my desktop ?
hackoo2011-03-15 08:36:28

jvierra
Posts: 13915
Joined: Tue May 22, 2007 9:57 am
Contact:

How to create a shortcut to my HTA ?

Post by jvierra » Tue Mar 15, 2011 1:45 am

Right click and drag file to desktop then select 'Create Shortcut'

User avatar
hackoo
Posts: 103
Joined: Sat Jan 22, 2011 12:27 am

How to create a shortcut to my HTA ?

Post by hackoo » Tue Mar 15, 2011 2:03 am

No (^_^) I know this ! but I wonder with code ?

When running a HTA, we cannot use the default methods for accessing the WScript. like WScript.ScriptFullName for replacing this variable HTA_Name="SMTP-GMAIL.hta" in the code . this what i mean !

Code: Select all

sub Shortcut
dim shell,DesktopPath,link,FSO
Set Shell = CreateObject("WScript.Shell")
Set FSO = CreateObject("Scripting.FileSystemObject")
CurrentFolder = shell.CurrentDirectory
MsgBox "This is The First Time for running this Application"&vbCrLf& "So We must Install a shorcut on your Desktop",48,"This is The First Time for running this Application"
MsgBox "The Current Directory is " & CurrentFolder,64,"Current Directory"
DesktopPath = Shell.SpecialFolders("Desktop")
Msgbox "The Target Directory is " & DesktopPath,64,"Target Directory"
HTA_Name="SMTP-GMAIL.hta"
Set link = Shell.CreateShortcut(DesktopPath & "SMTP GMAIL.lnk")
link.Description = "SMTP GMAIL"
link.IconLocation = CurrentFolder & "icon.ico"
link.TargetPath = CurrentFolder & "" & HTA_Name
link.WorkingDirectory = CurrentFolder
link.Save
MsgBox "The Shortcut is installed Sucsessfully ! !",64,"The Shortcut is installed Sucsessfully " 
end sub

    Sub window_onload()
    Dim link,shell,FSO
    Set Shell = CreateObject("WScript.Shell")
Set FSO = CreateObject("Scripting.FileSystemObject")
DesktopPath = Shell.SpecialFolders("Desktop")
link = DesktopPath & "SMTP GMAIL.lnk"
If FSO.FileExists(link)  Then
        CenterWindow 475, 620
  Else
        Call Shortcut
  MsgBox "Close This window and Re-Run it From Your Desktop Shortcut" &vbCrLf& "THANK YOU !",48,"Close This window and Re-Run it"
End If        
    End Sub
    
    Sub CenterWindow(x,y)
        window.resizeTo x, y
        iLeft = window.screen.availWidth/2 - x/2
        itop = window.screen.availHeight/2 - y/2
        window.moveTo ileft, itop
    End Sub
hackoo2011-03-15 09:04:48

User avatar
hackoo
Posts: 103
Joined: Sat Jan 22, 2011 12:27 am

How to create a shortcut to my HTA ?

Post by hackoo » Tue Mar 15, 2011 2:38 am

Thank you very much ! This is what i need ! it's very Helpful !

Locked