Jump to content

How to win7 x64 folder share/unshare?


youtuber
 Share

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
Link to comment
Share on other sites

  • Developers

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.
  :)

Link to comment
Share on other sites

Maybe you can find your happyness in this thread ?

 

My video tutorials : ( 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

 

Link to comment
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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...