sliceofpie Posted August 3, 2011 Share Posted August 3, 2011 Hello Everyone, Is there a way to find out if a selected folder is shared? From the command prompt I can run "NET VIEW \\LOCALHOST" which shows me the folders that are shared. I'm wondering if I can do this through AutoIT... so if I select a directory using TreeView, it first checks if the folder is shared over the network. Not quite sure if that's quite enough explanation. Anyhow, if someone can point me in the right direction I would really appreciate it!!! Thank you .. :) Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 4, 2011 Share Posted August 4, 2011 One way would be _Net_Share_ShareGetInfo() but that assumes you know the name of the share (it doesn't have to match the folder name).Better would be using the WinAPIEx.au3 UDF function _WinAPI_ShellGetFileInfo() to get the $tSHFILEINFO struct, and pull the "Attributes" field out of that, then check it for the SFGAO_SHARE bit. This way you can check a given folder without having to guess what the shared name might have been: #include <WinAPIEx.au3> Global Const $SFGAO_SHARE = 0x00020000 $sFolder = "C:\Temp" $tSHFILEINFO = DllStructCreate($tagSHFILEINFO) _WinAPI_ShellGetFileInfo($sFolder, $SHGFI_ATTRIBUTES, 0, $tSHFILEINFO) $iAttributes = DllStructGetData($tSHFILEINFO, "Attributes") If BitAND($iAttributes, $SFGAO_SHARE) Then ConsoleWrite("Attributes = 0x" & Hex($iAttributes) & "; Shared!" & @LF) Else ConsoleWrite("Attributes = 0x" & Hex($iAttributes) & "; NOT Shared!" & @LF) EndIf Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
sliceofpie Posted August 5, 2011 Author Share Posted August 5, 2011 PsaltyDS,Thank you for the great insight! This works great Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 5, 2011 Share Posted August 5, 2011 Glad it helped. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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