Jump to content
Sign in to follow this  
youtuber

How to win7 x64 folder share/unshare?

Recommended Posts

How to share a folder as in the picture or remove it from the share?

Spoiler

XM2rVO.jpg

And I also want to check permission = Full Control,Change,Read

#RequireAdmin
#include <NetShare.au3>

Local $sShareFolderNameAndDir = @DesktopDir & "\AutoIt Share Folder"
Local $sShareName = "AutoIt Share Folder"

$aInfo = _Net_Share_ShareGetInfo(@ComputerName, $sShareName)
$PermissionSharedInfo = _Net_Share_PermStr($aInfo[3])

If _Net_Share_ShareCheck(@ComputerName, $sShareName) = -1 Then
    ConsoleWrite("Not shared " & $sShareFolderNameAndDir & @CRLF)
    _Net_Share_ShareAdd(@ComputerName, $sShareName, 0, $sShareFolderNameAndDir, "Share Comment Folder")
    ConsoleWrite("Permission shared " & $PermissionSharedInfo & " " & $sShareFolderNameAndDir & @CRLF)
Else
    _Net_Share_ShareDel(@ComputerName, $sShareName)
    ConsoleWrite("Removed from sharing " & $sShareFolderNameAndDir & @CRLF)
    ConsoleWrite("Permission shared " & $PermissionSharedInfo & " " & $sShareFolderNameAndDir & @CRLF)
EndIf

 

Edited by youtuber

Share this post


Link to post
Share on other sites

You are around long enough to know you need to check for success/errors of performed functions, so start with adding error checking like is done in the example for  _Net_Share_ShareGetInfo(),

Jos


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites

Maybe you can find your happyness in this thread ?

 


My video tutorials : HERE ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites

I found the solution, but what is the NetShare.au3 equivalent?

#RequireAdmin
#include <process.au3>
Local $sShareFolderName = "AutoIt Share Folder"
Local $sSharedDir = @DesktopDir & "\" & $sShareFolderName

_RunDos("net share " & $sShareFolderName & "=" & $sSharedDir & " /GRANT:Everyone,FULL")
;share delete
_RunDos("net share " & $sShareFolderName & " /DELETE")
;or
 _Net_Share_ShareDel(@ComputerName, $sShareFolderName)

 

Edited by youtuber

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...