Shortcut op desktop (VB)

Status
Niet open voor verdere reacties.

Danielxmovies

Gebruiker
Lid geworden
8 okt 2011
Berichten
300
Hallo,

Ik wil in mijn programmatje dat ie een shortcut maakt op desktop.

Kan dit zonder externe dll?
 
Dat snap ik even niet.

Locatie van executable ergens neerzetten? :confused:
 
Ehm dit maakt een shortcut van je eigen programma denk.

maar kan ik doen dat bijv mijn programma een shortcut maakt van andere exe.

Dus bijv.

C://hallo.exe

Komt een shortcut van in je desktop?
 
IconPath en TargetPath van het shortcut-object veranderen.
 
die is zo groot :( :P

9 errors.

Imports IWshRuntimeLibrary

werkt niet
 
Laatst bewerkt door een moderator:
Kom op, joh:

How do I create a Shortcut on the Desktop from VB.NET or C#.Net? I also need to pass a user id and password so that I can launch the program and log it on to the database without the user having to login. In VB6, you had to use the Windows Scripting DLL. In .NET, since this facility has not been moved to the Framework, you still must use the same approach through Com Interop.

To get started creating a Shortcut on the Desktop, you must include a Reference to the Windows Scripting Library. You do this by right-clicking on the References folder in the Solution Explorer. Select the Add Reference menu. From the Add Reference dialog, click the Com Tab and select the Windows Scripting Host Object Model and click the Add button.

Moet ik alles voorkauwen? :(
 
Ja sorry nu heeft ie problemen met WshShell en hoe activereer ik de Shortcut maker?
 
Laatst bewerkt:
'k Heb de code aangepast, nu is-ie iets korter:

Code:
Imports IWshRuntimeLibrary
[cpp]Private Sub CreateShortCut(Path_Exe As String, Dir_Shortcut As String)
Try
Dim shell As New WshShell
Dim DesktopDir As String = Dir_Shortcut
Dim shortCut As IWshRuntimeLibrary.IWshShortcut
shortCut = CType(shell.CreateShortcut(DesktopDir & "\test.lnk"), IWshRuntimeLibrary.IWshShortcut)
With shortCut
.TargetPath = Path_Exe
.WindowStyle = 1
.Description = "Beschrijving"
.WorkingDirectory = DesktopDir
.IconLocation = Path_Exe & ", 0"
.Save()
End With
Catch ex As Exception
''//Evt fouten handlen
End Try
End Sub[/cpp]
 
Laatst bewerkt:
Oke Mooi

Shell fouten zijn weg targets ingedaan.

Nu alleen nog de shortcut creator.

Hoe start ik die?

Gewoon CreateShortcutter()

werkt niet
 
Zoals je ziet kunnen functies ook argumenten hebben.

[cpp]CreateShortCut("C:\Hallo.exe", My.Computer.FileSystem.SpecialDirectories.Desktop)[/cpp]
 
Taai spul JoZ1.
Goed kauwen hoor! :cool:
 
Laatst bewerkt door een moderator:
Jah

Jah :P

Maar hij maakt de file niet aan:

[CPP] Private Sub CreateShortCutOT(ByVal Dir_Shortcut As String)
Try
Dim shell As New WshShell
Dim DesktopDir As String = Dir_Shortcut
Dim shortCut As IWshRuntimeLibrary.IWshShortcut
shortCut = CType(shell.CreateShortcut(DesktopDir & "\test.lnk"), IWshRuntimeLibrary.IWshShortcut)
With shortCut
.TargetPath = (TextBox1.Text + "\Island Craft\Island_Craft_Installer.exe")
.WindowStyle = 1
.Description = "Island Craft"
.WorkingDirectory = DesktopDir
.IconLocation = (TextBox1.Text + "\Island Craft\Island_Craft_Installer.exe") & ", 0"
.Save()
End With
Catch ex As Exception
''//Evt fouten handlen
End Try
Process.Start(TextBox1.Text + "\Island Craft\Island_Craft_Installer.exe")
Me.Close()[/CPP]
 
Zo is het ook niet de bedoeling, dat is niet wat JoZ1 zegt.
En je mist nog een stukje van zijn voorbeeld.
 
edmoor zei:
Taai spul JoZ1.
Goed kauwen hoor! :cool:
Inderdaad edmoor :D
Maar ik ben een alleseter :P


@Danielxmovies:
Je hebt inderdaad mijn voorbeeld ingrijpend aangepast. Vandaar dat 't niet meer werkt.
Probeer dit eens:

[cpp]Private Sub CreateShortCutOT()
Try
Dim shell As New WshShell
Dim shortCut As IWshRuntimeLibrary.IWshShortcut
shortCut = CType(shell.CreateShortcut(My.Computer.FileSystem.SpecialDirectories.Desktop & "\test.lnk"), IWshRuntimeLibrary.IWshShortcut)
With shortCut
.TargetPath = (TextBox1.Text + "\Island Craft\Island_Craft_Installer.exe")
.WindowStyle = 1
.Description = "Island Craft"
.WorkingDirectory = My.Computer.FileSystem.SpecialDirectories.Desktop
.IconLocation = (TextBox1.Text + "\Island Craft\Island_Craft_Installer.exe") & ", 0"
.Save()
End With
Catch ex As Exception
''//Evt fouten handlen
End Try
Process.Start(TextBox1.Text + "\Island Craft\Island_Craft_Installer.exe")
Me.Close()
End Sub[/cpp]
 
Laatst bewerkt:
Je bent te goed voor deze wereld :p

Het enige argument kan zo trouwens ook wel weg.
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan