none
How to create a shortcut folder with a file type folder RRS feed

All replies

  • Hi,

    add reference Windows Script Host Object Model:

    Imports System.IO
    Imports IWshRuntimeLibrary
    
    Public Class Form1
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            CreateShortcutOnDesktop("minecraft", "E:\...")
        End Sub
        Public Shared Sub CreateShortcut(ByVal directory As String, ByVal shortcutName As String, ByVal targetPath As String, ByVal Optional description As String = Nothing, ByVal Optional iconLocation As String = Nothing)
            If Not System.IO.Directory.Exists(directory) Then
                System.IO.Directory.CreateDirectory(directory)
            End If
    
            Dim shortcutPath As String = Path.Combine(directory, String.Format("{0}.lnk", shortcutName))
            Dim shell As WshShell = New WshShell()
            Dim shortcut As IWshShortcut = CType(shell.CreateShortcut(shortcutPath), IWshShortcut)
            shortcut.TargetPath = targetPath
            shortcut.WorkingDirectory = Path.GetDirectoryName(targetPath)
            shortcut.WindowStyle = 1
            shortcut.Description = description
            shortcut.IconLocation = If(String.IsNullOrWhiteSpace(iconLocation), targetPath, iconLocation)
            shortcut.Save()
        End Sub
        Public Shared Sub CreateShortcutOnDesktop(ByVal shortcutName As String, ByVal targetPath As String, ByVal Optional description As String = Nothing, ByVal Optional iconLocation As String = Nothing)
            Dim desktop As String = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)
            CreateShortcut(desktop, shortcutName, targetPath, description, iconLocation)
        End Sub
    End Class
    

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Ahda Muammar Monday, April 22, 2019 2:45 AM
    • Unmarked as answer by Ahda Muammar Monday, April 22, 2019 3:22 AM
    Monday, April 22, 2019 2:20 AM
  • the command above is an error, how do you want to enter the mklink command on vb net?
    Monday, April 22, 2019 2:36 AM
  • the command above is an error, how do you want to enter the mklink command on vb net?

    Hi,

    I test it,it works well,create a desktop shortcut,where is the error?

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, April 22, 2019 2:44 AM
  • I want to make the shortcut on C:\ Users\Administrator\AppData\Roaming\ .minecraft
    and the source file where I want to run the program, what is the code please help
    Monday, April 22, 2019 2:50 AM
  • or how to mklink / d on vb net
    Monday, April 22, 2019 2:56 AM
  • I want to make the shortcut on C:\ Users\Administrator\AppData\Roaming\ .minecraft
    and the source file where I want to run the program, what is the code please help

    If you want to make the shortcut on C:\ Users\Administrator\AppData\Roaming\ .minecraft,fix the code:

     Public Shared Sub CreateShortcutOnDesktop(ByVal shortcutName As String, ByVal targetPath As String, ByVal Optional description As String = Nothing, ByVal Optional iconLocation As String = Nothing)
            Dim desktop As String = "C:\ Users\Administrator\AppData\Roaming\ .minecraft"
            CreateShortcut(desktop, shortcutName, targetPath, description, iconLocation)
        End Sub

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, April 22, 2019 3:01 AM
  • it's a folder with shortcut types, I want the folder to be a file folder type
    Monday, April 22, 2019 3:10 AM
  • or how to mklink / d on vb net

    use cmd.exe:

    https://stackoverflow.com/questions/15621294/how-to-run-windows-command-mklink-from-vb-net-application


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, April 22, 2019 3:11 AM
  • it doesn't solve the problem
    Monday, April 22, 2019 3:19 AM
  • it's a folder with a type of shortcut, I want to type of file = File folder (.minecraft)

    Monday, April 22, 2019 3:29 AM
  • it's a folder with shortcut types, I want the folder to be a file folder type

    Hi,

    You mean you don't have to create shortcuts? Instead, assign the folder to another location?

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, April 22, 2019 3:30 AM
  • yes I want to make it like mklink
    Monday, April 22, 2019 3:34 AM
  • Hi,

    method of moving folders:

     Public Shared Sub CopyFolder(ByVal strFromPath As String, ByVal strToPath As String)
            If Not Directory.Exists(strFromPath) Then
                Directory.CreateDirectory(strFromPath)
            End If
    
            Dim strFolderName As String = strFromPath.Substring(strFromPath.LastIndexOf("\") + 1, strFromPath.Length - strFromPath.LastIndexOf("\") - 1)
    
            If Not Directory.Exists(strToPath & "\" & strFolderName) Then
                Directory.CreateDirectory(strToPath & "\" & strFolderName)
            End If
    
            Dim strFiles As String() = Directory.GetFiles(strFromPath)
    
            For i As Integer = 0 To strFiles.Length - 1
                Dim strFileName As String = strFiles(i).Substring(strFiles(i).LastIndexOf("\") + 1, strFiles(i).Length - strFiles(i).LastIndexOf("\") - 1)
                IO.File.Copy(strFiles(i), strToPath & "\" & strFolderName & "\" & strFileName, True)
            Next
    
            Dim dirInfo As DirectoryInfo = New DirectoryInfo(strFromPath)
            Dim ZiPath As DirectoryInfo() = dirInfo.GetDirectories()
    
            For j As Integer = 0 To ZiPath.Length - 1
                Dim strZiPath As String = strFromPath & "\" & ZiPath(j).ToString()
                CopyFolder(strZiPath, strToPath & "\" & strFolderName)
            Next
        End Sub

    mklink:

     Dim arma2oaAddons = "D:\pdf2"
            Dim arma2Addons = "D:\pdf1"
            Dim process As New Process
            process.StartInfo.FileName = "cmd.exe"
            process.StartInfo.Arguments = "/c mklink """ + arma2oaAddons + """ """ + arma2Addons + """ /j"
    
            process.Start()

    https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2008-R2-and-2008/cc753194(v=ws.10)

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Ahda Muammar Monday, April 22, 2019 8:15 AM
    • Unmarked as answer by Ahda Muammar Monday, April 22, 2019 8:42 AM
    Monday, April 22, 2019 5:37 AM
  • the mklink works but I don't understand how to use the method of moving folders. and whether it is as I expected, please give the complete code
    Monday, April 22, 2019 7:37 AM
  • how to make

    Dim arma2Addons = "D:\pdf1"

    without drive D: or whatever, but where the application is run that's where it is

    Monday, April 22, 2019 8:13 AM
  • how to make

    Dim arma2Addons = "D:\pdf1"

    without drive D: or whatever, but where the application is run that's where it is

    Hi,

    following code create a pdf2.lnk,if you want to copy folder,use CopyFolder(ByVal strFromPath As String, ByVal strToPath As String),

    Dim arma2oaAddons = "D:\pdf2"
            Dim arma2Addons = "D:\pdf1"
            Dim process As New Process
            process.StartInfo.FileName = "cmd.exe"
            process.StartInfo.Arguments = "/c mklink """ + arma2oaAddons + """ """ + arma2Addons + """ /j"
    
            process.Start()

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, April 22, 2019 8:58 AM