2015-01-03 9 views
1

에 바로 가기 만들기 :나는이 코드를 가지고이 문제를주고 시작 프로그램 폴더 (VB.NET)

Imports IWshRuntimeLibrary 
Imports Shell32 

Public Sub CreateShortcutInStartUp(ByVal Descrip As String) 
    Dim WshShell As WshShell = New WshShell() 
    Dim ShortcutPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Startup) 
    Dim Shortcut As IWshShortcut = CType(WshShell.CreateShortcut(ShortcutPath &  
    Application.ProductName & ".lnk"), IWshShortcut) 
    Shortcut.TargetPath = Application.ExecutablePath 
    Shortcut.WorkingDirectory = Application.StartupPath 
    Shortcut.Descripcion = Descrip 
    Shortcut.Save() 
End Sub 

내가 읽은 내용에 따르면, 이것은 당신이 시작에 바로 가기를 만들 방법이다. 그러나, 내가이 Sub라고 얼마나 많이 부르더라도 지름길은 나타나지 않는다. 나는 S.O와 다른 여러 사이트에 대해 비슷한 질문을 많이합니다.

다른 응용 프로그램에서 바로 가기를 만들려고했지만 여전히 예상대로 나타나지 않습니다.

무엇이 누락 되었습니까?) 당신을

Dim Shortcut As IWshShortcut = CType(WshShell.CreateShortcut(System.IO.Path.Combine(ShortcutPath, Application.ProductName) & ".lnk"), IWshShortcut) 

2 : 이것에

Dim Shortcut As IWshShortcut = CType(WshShell.CreateShortcut(ShortcutPath & Application.ProductName & ".lnk"), IWshShortcut) 

: 그래서이 변경 경로가 제대로 연결된되지 않는

1) :

+0

무엇 Windows 버전 :

여기
Shortcut.Description = Descrip 

가 고정 서브 루틴입니까? – OneFineDay

+0

@OneFineDay Windows 7 Home Basic – soulblazer

답변

2

당신은 당신의 코드에서이 오류가 철자가 틀린 내용이므로 변경 :

Shortcut.Descripcion = Descrip 
이에3210

:

Public Sub CreateShortcutInStartUp(ByVal Descrip As String) 
    Dim WshShell As WshShell = New WshShell() 
    Dim ShortcutPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Startup) 
    Dim Shortcut As IWshShortcut = CType(WshShell.CreateShortcut(System.IO.Path.Combine(ShortcutPath, Application.ProductName) & ".lnk"), IWshShortcut) 
    Shortcut.TargetPath = Application.ExecutablePath 
    Shortcut.WorkingDirectory = Application.StartupPath 
    Shortcut.Description = Descrip 
    Shortcut.Save() 
End Sub