Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def makesmbconnection(driveletter,server,share,user,password,persistent):
- if (persistent==False):
- smbcommand = r"net use %s \\%s\%s %s /USER:%s /PERSISTENT:NO"%(driveletter,server,share,password,user)
- else:
- smbcommand = r"net use %s \\%s\%s %s /USER:%s /PERSISTENT:YES"%(driveletter,server,share,password,user)
- try:
- smbc = subprocess.Popen(smbcommand,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
- stdout, stderr = smbc.communicate()
- print "%s %s"%(stdout,stderr)
- except:
- print "error."
- shell output:
- >>> makesmbconnection("M:","127.0.0.1","D","Home","password",False)
- net use M: \\127.0.0.1\D password /USER:Home /PERSISTENT:NO
- The command completed successfully.
- C:\Users\Home>M:
- The system cannot find the drive specified.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement