programming symbolic links RRS feed

  • Question

  • Using Visual Basic express edition,

    I would like to make a small application to create and check symbolic links.

    it shall be like a grafical interface for Commands: 'mklink' and 'fsutil reparsepoint query'

    I already found ways to creta a symbolic link ( API CreateSymbolicLink )

    but could not find any API for fsutil query.

    If someone can give Information, maybe in C++,

    I would be grateful.

    Tuesday, April 20, 2010 4:31 PM

All replies

  • Hi Werner,

    You will need to elaborate your question.

    What's the "'mklink' and 'fsutil reparsepoint query'"?

    How do you creta a symbolic link ( API CreateSymbolicLink)?

    More context information will help us understand your questuon.

    Best regards,
    Martin Xie

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Friday, April 23, 2010 9:38 AM
  • Hi Martin,

    'mklink' is a Command line tool available in Windows 7 Command Box
    + to start Command Box, type 'cmd.exe' in [Taskbar] Start + [Input field]
      mklink creates symbolic links.
    > for the Windows API I used see
      Function CreateSymbolicLink

    'fsutil' is also a Command line tool available in Windows 7 Command Box
    + used as 'fsutil reparsepoint query <filename>'
      it delivers information about a symbolic link.

    > I search for Windows API ( one or several )
      to get Information like 'fsutil' delivers.
      I can read C++ Code and translate to Visual Basic (Version Express 2008)
      so an Example would be very helpful.

    > If you are interested, I worked out a Visual Basic Script
      which can de-code the Information delivered by 'fsutil'
      If wanted, please inform me where I could send this file. 

    Best regards and Thanks
    Werner Weingartner

    Tuesday, April 27, 2010 9:31 AM
  • I know this is an old thread, but I couldn't find a better place. Can anyone tell me how to use fsutil programmatically? Mr. Weingartner, I would like to see the code, if you have it still.
    Monday, March 21, 2011 6:52 PM
  • For Sowrabh and Satyadeep Karnati I add here more Info


    Use Command 'fsutil' programmatically

    In Visual Basic or Visual Basic Script,
    create a Shell Server instance
    and run the command in this server.
    Create Shell Server in VBScript or VB Version 6:
      Set ShellServ = CreateObject("WScript.Shell")
    Create Shell Server in VB.Net or higher:
      ShellServ = CreateObject("WScript.Shell")
    Run in VB or VBS
      ShellServ.Run "cmd.exe /c fsutil reparsepoint query " & <path-name> & ">" & <temp-file>, 0, True
    - - - - - -
    more Info for the parts of this Code:

    cmd.exe /c fsutil reparsepoint query   is the command exactly as it would be
    ====================================   typed in the command window.

    <path-name>   is to be replaced by the full Path and Name
    ===========   of the (link) file to be queried
    + can be a literal string or a variable containing the string

     & ">" &    re-route the command output
    =========   to a file

    <temp-file>   is to be replaced by the full Path and Name
    ===========   of a file to receive the output from the command
    + can be a literal string or a variable containing the string
    + will usually be a temporary file in TEMP Folder
    To use the result, read the fsutil command output file
    in VBScript:
      Set FileServ = CreateObject("Scripting.FileSystemObject")
      Set InpStream = FileServ.OpenTextFile( <temp-file> )
    in VB .Net or higher:
      Dim InpStream As System.IO.StreamReader = New System.IO.StreamReader( <temp-file> )

    The data read from fsutil command are strings;
    the following is the Code for a procedure
    which will de-code the data.
    The Code is given for VBScript.

    Function Data_DeCode(CmdOutStr)
    ' CmdOutStr   shall contain the data read from fsutil command
    '   including the Newline control bytes.

      Dim RowStr, ChaPos, FndTar
        ChaPos = InStr(CmdOutStr, vbcrlf)
        If 0 = ChaPos Then
          RowStr = CmdOutStr
          CmdOutStr = ""
          RowStr = Left(CmdOutStr, ChaPos - 1)
          CmdOutStr = Mid(CmdOutStr, ChaPos + 2)
        End If
        If Not "" = RowStr Then
            ' ----+----1----+
          If "Print Name:" = Left(RowStr, 11) Then
            FndTar = RTrim(Mid(RowStr, 24))
            Exit Do
          End If
        End If
      Loop Until "" = CmdOutStr

    ' the result will be the so-called print name of the link-target;
    ' in most cases, that will be the full path-name of the target.

    Sunday, March 27, 2011 7:03 PM