Sign in to follow this  
Followers 0
sliceofpie

Shared Folders

4 posts in this topic

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 .. :mellow::) :) :blink::):party:

Share this post


Link to post
Share on other sites



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

:mellow:


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

Share this post


Link to post
Share on other sites

PsaltyDS,

Thank you for the great insight! :mellow: This works great Posted Image Posted Image Posted Image

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0