ASPN ActiveState Programmer Network  
ActiveState, a division of Sophos
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups
Submit Recipe
My Recipes

All Recipes
All Cookbooks


View by Category

Title: creating a share on windows with python
Submitter: John Nielsen (other recipes)
Last Updated: 2004/09/03
Version no: 1.0
Category: System

 

Not Rated yet


Description:

The following code is an example of how one would use python's win32net module to create a share on windows.

Source: Text Source

import win32net
import win32netcon

shinfo={}

shinfo['netname']='python test'
shinfo['type']=win32netcon.STYPE_DISKTREE
shinfo['remark']='data files'
shinfo['permissions']=0
shinfo['max_uses']=-1
shinfo['current_uses']=0
shinfo['path']='c:\\my_data'
shinfo['passwd']=''
server='servername'

win32net.NetShareAdd(server,2,shinfo)

Discussion:

The python win32 documentation is rather terse about what you need to create a share with win32net. It comments that you need a dictionary holding the share data, in the format of SHARE_INFO_*. You'd need to consult the win32 SDK (try http://msdn.microsoft.com) to find out what that really means. After doing so, you end up with a data structure like the python dictionary above. And, the constants you need for the data structure are located in the win32netcon module.



Add comment

No comments.



Highest rated recipes:

1. A simple XML-RPC server

2. Web service accessible ...

3. IPy Notify

4. Changing return value ...

5. Quantum Superposition

6. Pickle objects under ...

7. Generalized delegates ...

8. Reorder a sequence (uses ...

9. Setting Win32 System ...

10. ObjectMerger




Privacy Policy | Email Opt-out | Feedback | Syndication
© 2006 ActiveState Software Inc. All rights reserved.