Jump to content

Creating Network Share


jgira
 Share

Recommended Posts

Is it possible to create a network share and set the permissions on the share using AutoIt? We are currently looking to lock down our workstations by disabling the network shares and creating a new one for use with our IS department only.

Thanks in advance! :)

Gira

Link to comment
Share on other sites

Is it possible to create a network share and set the permissions on the share using AutoIt? We are currently looking to lock down our workstations by disabling the network shares and creating a new one for use with our IS department only.

From the command line: NET HELP SHARE

You can get fancier, with WMI calls and SetACL.exe for the permissions... how much AutoIt coding are you comfortable with?

:)

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

From the command line: NET HELP SHARE

You can get fancier, with WMI calls and SetACL.exe for the permissions... how much AutoIt coding are you comfortable with?

:)

Thanks for the reply. I am familiar with the net commands. I did look at using the NET commands but there is a limitation. With the NET SHARE command, you cannot set the permissions on the share. I am comfortable with AutoIt (as I use it for all of my scripting needs, application deliveries, system changes, etc) but am unfamiliar how to go about this with WMI and SetACL.exe. Any tips or ideas?

Thanks again for replying!

Gira

Link to comment
Share on other sites

Thanks for the reply. I am familiar with the net commands. I did look at using the NET commands but there is a limitation. With the NET SHARE command, you cannot set the permissions on the share. I am comfortable with AutoIt (as I use it for all of my scripting needs, application deliveries, system changes, etc) but am unfamiliar how to go about this with WMI and SetACL.exe. Any tips or ideas?

Thanks again for replying!

Gira

For using WMI with shares, you would refer to Win32_Share in MSDN, and use AutoIt's COM Object capabilities:

$FILE_SHARE = 0
$MaxConn = 25
$ShareFolder = "C:\Temp"
$ShareName = "Temp"
$ShareDesc = "Temporary Files"
$sComputerName = @ComputerName

$oWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $sComputerName & "\root\cimv2")
If IsObj($oWMI) Then
    $oWin32_Share = $oWMI.Get ("Win32_Share")
    If IsObj($oWin32_Share) Then
        $RET = $oWin32_Share.Create ($ShareFolder, $ShareName, $FILE_SHARE, $MaxConn, $ShareDesc)
        If $RET = 0 Then
            ConsoleWrite("Debug: Successfully created share." & @LF)
        Else
            ConsoleWrite("Debug: Error!  $oWin32_Share.create returned " & $RET & @LF)
        EndIf
    Else
        ConsoleWrite("Debug: Error!  Error connecting to the Win32_Share service." & @LF)
    EndIf
Else
    ConsoleWrite("Debug: Error!  Error connecting to the WMI service." & @LF)
EndIf

; Release obj vars
$oWMI = ""
$oWin32_Share = ""

I've been using SetACL.exe to set perms on all kinds of things, including CIFS shares. This can be done with additional WMI functions, but I'm not fluent in them yet, so I go with the command line version of SetACL.exe, and run it from my AutoIt scripts.

:)

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

@jgira

Or you can use SetACL COM Object

Regards,

ptrex

@ptrex,

That uses the SetACL.ocx for the COM interface (which is very cool, BTW). I thought I remembered seeing you or another person found some of this functionality in native WMI calls without reference to an external executable. Do you remember where that might have been?

:)

Edit: Something to do with SetSecurityDescriptor Method of the Win32_SecuritySetting Class, I think...

Edited by PsaltyDS
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

@ptrex,

That uses the SetACL.ocx for the COM interface (which is very cool, BTW). I thought I remembered seeing you or another person found some of this functionality in native WMI calls without reference to an external executable. Do you remember where that might have been?

:)

Edit: Something to do with SetSecurityDescriptor Method of the Win32_SecuritySetting Class, I think...

I got it working using SetACL.exe and NET SHARE commands. Thanks guys for the help! :P

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