0

i was trying to remote from a windows machine (this machine has python26 installed) to another windows machine (this machine doesnt has python installed) using python script. i googled through and found out that WMI module is very good. so i tried using this. below is my code :

    class WindowsMachine:
        def __init__(self, ip, username, password, remote_path=REMOTE_PATH):
            self.ip = ip
            self.username = username
            self.password = password
            self.remote_path = remote_path
            try:
                print "Establishing connection to %s" %self.ip
                self.connection = wmi.WMI(self.ip, user=self.username, password=self.password)
                print "Connection established"
            except wmi.x_wmi:
                print "Could not connect to machine"
                raise

but im getting error message : wmi.x_access_denied". i have googled up for a solution for this but didnt get a proper answer. can someone please help? anyone encountered this before?

3
  • hi, after connection established, i would like to have a certain check. such as checking in a certain folder if there are files available, checking ages of files that are in certain folder. is there a better way to do this? i do not want to use ssh as this would require me to install ssh in both windows pc's Commented Sep 17, 2014 at 8:32
  • hi there. im sorry, check update in your answer? where is the update please? Commented Sep 18, 2014 at 2:31
  • Are you including the domain for your user in the username? Like this auth_user = '{0}\{1}'.format(domain, user) then try connecting wmic = wmi.WMI(host_ip, user=auth_user, password=password) Commented Sep 18, 2014 at 16:54

1 Answer 1

1

This issue is usually permission related. There is a good article on troubleshooting WMI here. In addition to that, I recommend using wmic (the WMI command line client) to isolate the problem before going back to the Python code.

Here is an example of wmic failing due to the user not being authenticated:

C:> wmic /node:10.0.0.1 os get caption
Node - 10.0.0.1
ERROR:
Code = 0x80070005
Description = Access is denied.
Facility = Win32

Here is the same command, but this time it succeeds because the user is authenticated:

C:> wmic /node:10.0.0.1 /user:example\user /password:123456 os get caption
Caption
Microsoft(R) Windows(R) Server 2003, Standard Edition
Sign up to request clarification or add additional context in comments.

1 Comment

hi Rod, i tried this commands, and got the same "access is denied" description. im looking at the article now

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.