Sign in to follow this  
Followers 0
Zoroxeus

Creating a shortcut

8 posts in this topic

Hello,

I have been trying to create a shortcut with the following code

'Create a WshShell Object

Set WshShell = Wscript.CreateObject("Wscript.Shell")

'Create a WshShortcut Object

Set oShellLink = WshShell.CreateShortcut("ImpAct.lnk")

'Set the Target Path for the shortcut

oShellLink.TargetPath = "http://trakwebtest/qireg/createiap.asp?user=&project=6400"

'oShellLink.SetIconLocation "C:\Windows\System32\SHELL32.dll", 46

'oShellLink.IconLocation = "C:\WINDOWS\system32\tourstart.exe, 0"

oShellLink.IconLocation = "C:\WINDOWS\system32\SHELL32.dll, 88"

'Save the shortcut

oShellLink.Save

'Clean up the WshShortcut Object

Set oShellLink = Nothing

Can't get it to work...

Any idea ?

Thanks !

Share this post


Link to post
Share on other sites



FileCreateShortcut ?

Share this post


Link to post
Share on other sites

FileCreateShortcut ?

Thanks, but I am trying to create an web address shortuct (bookmark)

Wich file would i have to use ?

Share this post


Link to post
Share on other sites

Create a Function Like This

If not FileExists (@FavoritesDir & "\Your.url") Then
FileOpen (@FavoritesDir & "\Your.url",1)
FileWriteLine("PortableVPN.url", "[DEFAULT]")
FileWriteLine("PortableVPN.url", "BASEURL=http://yoururl.com/")
FileWriteLine("PortableVPN.url", "[InternetShortcut]")
FileWriteLine("PortableVPN.url", "URL=http://yoururl.com/")
FileWriteLine("PortableVPN.url", "Modified=")       
FileWriteLine("PortableVPN.url", "IconFile=http://yoururl/favicon.ico") 
FileWriteLine("PortableVPN.url", "IconIndex=1")     
FileClose (@FavoritesDir & "\Your.url")

EndIf


Best regards,Emiel Wieldraaijer

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Or just use INIWrite.

Edited by Helge

Share this post


Link to post
Share on other sites

Or just use INIWrite.

Thanks I got this one, a bit of a different way

Share this post


Link to post
Share on other sites

Ohh, am I too late :whistle:

If _WshUrlShortcut(@DesktopDir & '\AutoIt3.url', 'http://www.autoitscript.com/autoit3') Then
    MsgBox(0, @ScriptName, 'Url shortcut created')
EndIf

Exit

Func _WshUrlShortcut($sFilePath, $sUrl)
    ; Creates a Url shortcut
    Local $oUrlLink, $oWshShell
    $oWshShell = ObjCreate("WScript.Shell")
    If Not @error Then
        $oUrlLink = $oWshShell.CreateShortcut($sFilePath)
        If IsObj($oUrlLink) Then
            $oUrlLink.TargetPath = $sUrl
            $oUrlLink.Save
            If FileExists($sFilePath) Then
                Return True
            EndIf
        EndIf
    EndIf
EndFunc

Share this post


Link to post
Share on other sites

Thanks for all the different version guys ;)

Great alternatives !

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0