Guest User

Untitled

a guest
Mar 29th, 2018
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1.  
  2. #! /usr/bin/python
  3.  
  4. __author__="Hari Priya"
  5.  
  6. import os
  7. import wmi
  8. import shutil
  9. import win32wnet
  10.  
  11.  
  12. REMOTE_PATH = 'c:\\'
  13.  
  14. def main():
  15. ip = '192.168.0.103'
  16. username = "hari"
  17. password = 'T!T@n1130'
  18. server = WindowsMachine(ip, username, password)
  19. '''print server.run_remote('ipconfig', async=False, output=True)'''
  20.  
  21. class WindowsMachine:
  22. def __init__(self, ip, username, password, remote_path=REMOTE_PATH):
  23. self.ip = ip
  24. self.username = username
  25. self.password = password
  26. self.remote_path = remote_path
  27. try:
  28. print("Establishing connection to %s" %self.ip)
  29. c = wmi.WMI(privileges=["security"])
  30. self.connection = wmi.WMI(self.ip, user=self.username, password=self.password)
  31. print("Connection established")
  32. except wmi.x_wmi:
  33. print("Could not connect to machine")
  34. raise
  35.  
  36. if __name__ == "__main__":
  37. main()
Add Comment
Please, Sign In to add comment