Jump to content

How to share a folder ?


Recommended Posts

Hello.

What I mean by "share a folder" :

In AutoIt, there is, between others, functions to work with map drives (DriveMapAdd, ...).

I have to install a legacy program (setup is on a network share that I can map in the script with DriveMapAdd).

This legacy program needs a share on the local c:\temp folder for the installation (and also after for execution).

Hence I want to do the equivalent windows command "net share temp=c:\temp", but with a function in AutoIt, but also WITHOUT using run("cmd /C net share...") in AutoIt.

jmd

What do you mean by "a function to share a folder"? Do you mean sharing a specified folder on your network?

If this is what u want you can do it by using the "net share" command, here is the full documentation http://www.microsoft.com/resources/documen...e.mspx?mfr=true

Edited by jmdess
Link to comment
Share on other sites

$strComputer = @ComputerName
$objWMIService = ObjGet("winmgmts:" & "{impersonationLevel=impersonate}!\\"& $strComputer & "\root\cimv2")
$objNewShare = $objWMIService.Get("Win32_Share")
$errReturn = $objNewShare.Create("C:\Finance", "FinanceShare", 0, 25, "Public share for the Finance group.")

This may help you...

Edited by JavaCupiX
Link to comment
Share on other sites

Hi,

ConsoleWrite(_freigebenOrdner("c:\downloads", "saugen", "Dies ist ein Freigabe test!"))
Sleep(5000)
ConsoleWrite(_freigebenOrdner("c:\downloads", "saugen", "", 1))

Func _freigebenOrdner($pfad, $freigabeName = "Datenfreigabe", $beschreibung = "Freigabe", $delete = 0)
    If $delete <> 0 Then
        Return RunWait(@ComSpec & ' /c net share ' & $freigabeName & ' /delete', '', @SW_HIDE)
    Else
        Return RunWait(@ComSpec & ' /c net share ' & $freigabeName & '=' & $pfad & ' /remark:"' & $beschreibung & '"', '', @SW_HIDE)
    EndIf
EndFunc  ;==>_freigebenOrdner

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Thank you very very much.

This works perfectly.

$strComputer = @ComputerName
$objWMIService = ObjGet("winmgmts:" & "{impersonationLevel=impersonate}!\\"& $strComputer & "\root\cimv2")
$objNewShare = $objWMIService.Get("Win32_Share")
$errReturn = $objNewShare.Create("C:\Finance", "FinanceShare", 0, 25, "Public share for the Finance group.")

This may help you...

Link to comment
Share on other sites

Hi,

ConsoleWrite(_freigebenOrdner("c:\downloads", "saugen", "Dies ist ein Freigabe test!"))
Sleep(5000)
ConsoleWrite(_freigebenOrdner("c:\downloads", "saugen", "", 1))

Func _freigebenOrdner($pfad, $freigabeName = "Datenfreigabe", $beschreibung = "Freigabe", $delete = 0)
    If $delete <> 0 Then
        Return RunWait(@ComSpec & ' /c net share ' & $freigabeName & ' /delete', '', @SW_HIDE)
    Else
        Return RunWait(@ComSpec & ' /c net share ' & $freigabeName & '=' & $pfad & ' /remark:"' & $beschreibung & '"', '', @SW_HIDE)
    EndIf
EndFunc ;==>_freigebenOrdner

So long,

Mega

^^ did you read the "but with a function in AutoIt, but also WITHOUT using run("cmd /C net share...") in AutoIt." before posting :whistle:
Link to comment
Share on other sites

Thank you.

But, if possible, I prefer not to launch another runwait by an external program (cmd.exe or other).

Hi,

ConsoleWrite(_freigebenOrdner("c:\downloads", "saugen", "Dies ist ein Freigabe test!"))
Sleep(5000)
ConsoleWrite(_freigebenOrdner("c:\downloads", "saugen", "", 1))

Func _freigebenOrdner($pfad, $freigabeName = "Datenfreigabe", $beschreibung = "Freigabe", $delete = 0)
    If $delete <> 0 Then
        Return RunWait(@ComSpec & ' /c net share ' & $freigabeName & ' /delete', '', @SW_HIDE)
    Else
        Return RunWait(@ComSpec & ' /c net share ' & $freigabeName & '=' & $pfad & ' /remark:"' & $beschreibung & '"', '', @SW_HIDE)
    EndIf
EndFunc ;==>_freigebenOrdner

So long,

Mega

Link to comment
Share on other sites

I don't get it... why is using wmi/vba/whatever better than using cmdline?

You don't see anything at all and you may read out all the stderror or stdout that's generated by cmdline-programs.

Just wondering... in this case, net is even bundled with windows. :whistle:

Edited by dabus
Link to comment
Share on other sites

@dabus : I had a few examples for this, for example if you are in a safe Citrix session (or internet cafe system with very restricted programs) you won't allow any cmd.exe or net to work... I also think that using run and things like that isn't the cleanest solution...

Link to comment
Share on other sites

Hi,

LOL funny thread.

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

@Xeno: What's so funny? Safety, Citrix and Autoit in one sentence?? :whistle:

Hi,

I found it funny because there are several solutions and nevertheless there is still a discussion.

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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