0

I'm very new to Python and trying to write a few short lines, one of them is supposed to share a folder (on windows) called C:\Projects

I'm a bit surprised but I couldn't really find much info on sharing folders, what am I missing?

I did some extensive Googling and searching in Stack Overflow but this is basically all I could find, and I think this only ADDS permissions to an already existing folder: creating permissions on shared windows folder with python

I need a very basic share where permissions are 'Read' to 'Everyone'.

Sorry if this is a very basic/simple question, I was able to Google everything else but this is stomping me.

Tomerikoo
  • 12,112
  • 9
  • 27
  • 37
Noamm
  • 1
  • 1
    You're possibly not getting answers because "sharing folders" is not something python does. It's a feature provided by filesystems & OSs. You should google how to create shared folders in your OS. From there you can then search how you can do that with python. – rdas Feb 23 '21 at 13:20
  • If you were trying to share folders because you want people to collaborate on them with you, you would probably want to use GitHub, or Visual Studio Code Live Share – coderman1234 Feb 23 '21 at 13:22
  • Who is "everyone"? Other users on the system? Colleagues in your office's network? Random perople on the internet? – couka Feb 23 '21 at 13:22
  • Thanks guys, the goal is to share a folder across a local network, not GitHub. By 'Everyone' I meant the 'Everyone' user object in windows - meaning everyone will be able to read the content of the folder when they open it via \\workstation\projects\ I was able to CREATE the folder using python (also part of the code), but I can't figure out how to share it. – Noamm Feb 23 '21 at 13:25
  • Hmm this is interesting. I will make an assumption from the backslashes that you are on windows, where most likely you would want to use SMB shares. Using [pywin32](https://pypi.org/project/pywin32/), you may be able to interact with the [Network Share Functions](https://docs.microsoft.com/en-us/windows/win32/netshare/network-share-functions) in the windows API to create SMB shares after creating the required folder. – R3uben Feb 23 '21 at 13:34
  • I think I understand what @rdas meant, I tried 'import os os.system('cmd /c "net share Projects=c:\Projects"')' But I'm getting access is denied which shouldn't really happen.. I guess I'll do some more digging.. Edit: Sorry, I don't know how to format properly in here.. – Noamm Feb 23 '21 at 13:37
  • If you go down the route of sharing by running a cmd command rather than leveraging win32 api, see [this post](https://stackoverflow.com/questions/89228/how-to-execute-a-program-or-call-a-system-command-from-python) about the advantages of using subprocess. At which point you could use `net share ShareName=C:\Projects ` Default 'share' permissions are set to read for 'Everyone'. The issues you are having above may be around running the command with elevated privileges. – R3uben Feb 23 '21 at 13:43

0 Answers0