VijaySaibola Posted June 26, 2018 Share Posted June 26, 2018 I need to check if a network share is mapped or not. The idea I got is to run a command "net use" and then parse the resulting text to find out if my network share is mapped or not. For example, here is a result for net use command: Quote Status Lokal Remote Netzwerk ------------------------------------------------------------------------------- F: \\192.168.100.23\share1 Microsoft Windows Network G: \\192.168.100.23\share2 Microsoft Windows Network I can search for a string "\\192.168.100.23\share1" to find if the share is already mapped or not. I need this method for searching because, I do not know in advance which Drive Letter is used for the network share. Also it is possible that the network share is mapped without a drive letter. Can anybody help, how I can run "net use" command and get the result in a text buffer so that I can parse it? I do not want to create a temporary text file (like net use >> c:\temp.txt) and then parse the text file. A different question but related. Is there an easy method in Autoit to get the drive letter for a network share which has been mapped? Thanks! Link to comment Share on other sites More sharing options...
Subz Posted June 26, 2018 Share Posted June 26, 2018 (edited) Why not use DriveGetDrives along with DriveMapGet? Local $aNetworkDrives = DriveGetDrive("Network") If @error Then MsgBox(4096, "Error", "No Network Drives found.") For $i = 1 To $aNetworkDrives[0] MsgBox(0, "Drive " & StringUpper($aNetworkDrives[$i]), StringUpper($aNetworkDrives[$i]) & " mapped to: " & DriveMapGet($aNetworkDrives[$i])) Next Edited June 26, 2018 by Subz Added simple example Link to comment Share on other sites More sharing options...
junkew Posted June 27, 2018 Share Posted June 27, 2018 https://www.autoitscript.com/autoit3/docs/functions/ConsoleRead.htm FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now