2

I want to get list of installed software on remote computer.For that I want to use python script in my android application.Now,I have a python script which is getting the list of installed software on remote computer.But,I don't know how to make it supported in android.
For this, I found SL4A android Scripting here . So, I tried to run my python script in android device using SL4A.But,It's not working and giving me error because some packages like win32.client is missing.I don't know more about SL4A so I don't know how to convert my python script in Android supported form.So,anyone have any idea or code please suggest me.....

Also If anyone have another way to get installed software list from remote Pc then please suggest...
Below is my python script

import wmi
from winreg import (HKEY_LOCAL_MACHINE, KEY_ALL_ACCESS, OpenKey, EnumValue, QueryValueEx)

c = wmi.WMI(computer="PC02",user="admin",password="a@1",namespace="root/default").StdRegProv
result, names = c.EnumKey (hDefKey=HKEY_LOCAL_MACHINE, sSubKeyName=r"Software\Microsoft\Windows\CurrentVersion\Uninstall")

print('These subkeys are found under "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"\n\n')

separator = "*" * 80
keyPath = r"Software\Microsoft\Windows\CurrentVersion\Uninstall"
count = 0

while count < len(names):

    try:      
        print(separator+'\n')

        path = keyPath + "\\" + names[count]
        key = OpenKey(HKEY_LOCAL_MACHINE, path, 0, KEY_ALL_ACCESS)
        temp = QueryValueEx(key, 'DisplayName')
        display = str(temp[0])
        print (" Name: "+display+'\n',"key:",names[count])

        count += 1
    except:
        print ("Key:",names[count])
        count += 1
        continue
krushnakant
  • 431
  • 9
  • 21
  • I indented your try/except group inside your while loop. This seems the correct way but please correct it if I'm wrong – joaquin Jan 28 '12 at 12:37
  • @joaquin Above code is working correctly on windows computer but It's not working in Android because WMI is directly not supported in Linux... – krushnakant Jan 28 '12 at 15:47

5 Answers5

3

Run the script on your remote computer, and expose the list of installed software on HTTP, a good way to write this simple web app is to use flask and its development server to serve the list of installed software, then write a python script which uses the native android web interface to fetch the list and display it.

rapadura
  • 5,242
  • 7
  • 39
  • 57
  • Thanks,but I don't want to use internet connection and I think for web app I have to use internet connection...... – krushnakant Jan 28 '12 at 15:49
  • You cant access a list of installed programs remotely without using a connection. Then its just locally. – rapadura Jan 28 '12 at 19:52
  • I am already connected to one Wi-FI Network.I want to get software information of computer which are in my Wi-Fi Network...... – krushnakant Jan 29 '12 at 08:32
  • That would be perfectly fine for the solution I described. On the computers which you want to see what software is installed on it, you run your web app which will use wmi to list the packages installed when asked (through a http get request), then on your phone you put your application to ask the computer what it has installed. – rapadura Jan 29 '12 at 17:31
  • I don't want to run anything on remote computer.I don't want to install any app in computer to run my android app.Can I use any inbuilt service which is already available on computer to get software information?? – krushnakant Feb 02 '12 at 08:45
  • "Can I use any inbuilt service which is already available on computer to get software information." No you cant, from an Android phone. – rapadura Feb 02 '12 at 14:15
2

You are having problems with missing libraries because you are importing windows specific ones. At any rate, this isn't the correct script to be running. This script seems to be for a computer, not an android phone.

  • Thanks for Response.I know that this script is for computer but what should i change in script to make it compatible to android phones??I am new to android and I also don't know more about SL4A or Python..... – krushnakant Jan 28 '12 at 12:50
  • I am not knowledgeable about android development, but the obvious solution (to me) is to create some sort app to run on the computer, and another app to run on the phone. The computer app will through some means (internet or wifi) publish a list of the programs installed. The phone app will then retrieve that list, and use it for what ever it does. – Thoughtful Dragon Jan 28 '12 at 17:35
  • Then there is no real way that I know of that can do that – Thoughtful Dragon Jan 29 '12 at 19:06
1

You're trying to use a Python script that uses Windows Management Instrumentation (WMI), on a device that doesn't have that library.

Sadly, WMI on Python requires the win32 library, which is only available on Windows. I don't think you're going to have much success on checking the installed programs on remote Windows computer from an Android device in this way.

cha0site
  • 10,517
  • 3
  • 33
  • 51
  • Thanks for Response,If this is not possible please suggest me if you have another way to get list of installed software from remote computer in android....... – krushnakant Jan 28 '12 at 13:09
  • @krushnakant: Can you run something on a server? Maybe write a webapp and then access that from your Android device. – cha0site Jan 28 '12 at 13:12
  • For webapp,I think I should have internet connection on Android device and I want software information without internet connection.I want to get software information of all device in my wi-fi network.... – krushnakant Jan 28 '12 at 15:43
  • 1
    @krushnakant: You can access a webapp on a server through Wi-Fi. – cha0site Jan 28 '12 at 15:44
  • Can I use SNMP?? I know that using SNMP I can get some information like "free memory", "system name", "number of running processes", "default route" etc using OIDs.But I don't know about software information......Any Idea?? – krushnakant Jan 29 '12 at 08:29
  • @krushnakant: Maybe try this: http://msdn.microsoft.com/en-us/library/windows/desktop/aa393621(v=vs.85).aspx – cha0site Jan 29 '12 at 08:56
0

Running python scripts is now achievable in gradle system using Tasks

task pythonFile(type:Exec) {
workingDir 'src_path'
commandLine 'python', 'my_script.py'
} 
Justcurious
  • 2,201
  • 1
  • 21
  • 36
0

Since WMI is based on WBEM, you may be able to use wbem to access it; you might want to try using pywbem, a pure python wbem library.

Lie Ryan
  • 62,238
  • 13
  • 100
  • 144