none
Automating mapping multiple drives with smartcard credentials

    Question

  • I am trying to create a small application map several network drives using a user supplied smartcard in VS2010. We have been using a batch script ("net use" command with /smartcard) for this but it requires the user to enter thier pin multiple times.

    So far I have been trying to use the "NET USE" command via a process but as soon as the "Reading smart cards..." response is given the process exits.

    Private Sub mntDrives(ByVal pin As String)
            Dim cmdinput As String = "Net use z: \\myserver\myfolder /persistent:no /smartcard"
            Dim ps As New Process
            ps.StartInfo.CreateNoWindow = True
            ps.StartInfo.UseShellExecute = False
            ps.StartInfo.FileName = "C:\Windows\System32\cmd.exe"
            ps.StartInfo.RedirectStandardOutput = True
            ps.StartInfo.RedirectStandardError = True
            ps.StartInfo.RedirectStandardInput = True
            ps.Start()
            ps.StandardInput.WriteLine(cmdinput)
            ps.StandardInput.WriteLine(pin)
            ps.StandardInput.Close()
            ps.WaitForExit() 'executes command here. Stops execution at first output. "Reading smart cards..."'
            txtOutput.AppendText(formatText(ps.StandardOutput.ReadToEnd))
            ps.Close()
            ps.Dispose()
        End Sub
    Is there a way around this?
    Tuesday, October 28, 2014 7:28 PM

Answers

All replies