jgira Posted August 14, 2007 Posted August 14, 2007 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
PsaltyDS Posted August 14, 2007 Posted August 14, 2007 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 SHAREYou 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
jgira Posted August 14, 2007 Author Posted August 14, 2007 From the command line: NET HELP SHAREYou 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
PsaltyDS Posted August 14, 2007 Posted August 14, 2007 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
ptrex Posted August 14, 2007 Posted August 14, 2007 @jgiraOr you can use SetACL COM ObjectRegards,ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New
PsaltyDS Posted August 14, 2007 Posted August 14, 2007 (edited) @jgiraOr you can use SetACL COM ObjectRegards,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 August 14, 2007 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
jgira Posted August 15, 2007 Author Posted August 15, 2007 @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!
ptrex Posted August 15, 2007 Posted August 15, 2007 @PsaltyDS I have seen that all happen in WMI. I'll check in my scripts see if I find something simular. Keep in touch. regards ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New
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