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.
This topic is 13 years and 2 weeks old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
hackoo
Posts: 103
Last visit: Tue Apr 26, 2016 9:02 am

How to create a shortcut to my HTA ?

Post by hackoo »

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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

How to create a shortcut to my HTA ?

Post by jvierra »

Right click and drag file to desktop then select 'Create Shortcut'
User avatar
hackoo
Posts: 103
Last visit: Tue Apr 26, 2016 9:02 am

How to create a shortcut to my HTA ?

Post by hackoo »

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
Last visit: Tue Apr 26, 2016 9:02 am

How to create a shortcut to my HTA ?

Post by hackoo »

Thank you very much ! This is what i need ! it's very Helpful !
This topic is 13 years and 2 weeks old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked