i hv written 2 programs. "process.py" and "Reg_write_read.py". I have created the exe of both,"Reg_write_read.py" program writes a value in registry through which the process.exe(which is located in C:/) executes on computer restart. But when i Restart my computer. the "process.exe.log" error log generates that says :
"Traceback (most recent call last):
File "<install zipextimporter>", line 1, in <module>
ImportError: No module named zipextimporter
Traceback (most recent call last):
File "process.py", line 1, in <module>
ImportError: No module named wmi"
. But when i write a value in registry which executes other exe file (which is not written through python) then its working fine.If i run process.exe mannually by double clicking on the process.exe then its working fine but not at the boot time
I dont understand what is wrong..Kindly Suggest..Thanks in advance.
THE CODE IS BELOW
---------------------
#Reg_write_read.py
---------------------------
from _winreg import *
print r"*** Reading from SOFTWARE\Microsoft\Windows\CurrentVersion\Run ***"
aReg = ConnectRegistry(None,HKEY_LOCAL_MACHINE)
aKey = OpenKey(aReg, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run")
for i in range(1024):
try:
n,v,t = EnumValue(aKey,i)
print i, n, v, t
except EnvironmentError:
print "You have",i," tasks starting at logon..."
break
CloseKey(aKey)
print r"*** Writing to SOFTWARE\Microsoft\Windows\CurrentVersion\Run ***"
aKey = OpenKey(aReg, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", 0, KEY_WRITE)
try:
SetValueEx(aKey,"MyNewKey",0, REG_SZ, r"c:\process.exe")
except EnvironmentError:
print "Encountered problems writing into the Registry..."
CloseKey(aKey)
CloseKey(aReg)
-------------------------------
#process.py
--------------------------
#List all Running Process
import wmi
c = wmi.WMI ()
for process in c.Win32_Process ():
print process.ProcessId, process.Name
pid=str(process.ProcessId)
pn=process.Name
f=open("proc.txt", "a")
f.write("\nProcess ID:")
f.write(pid)
f.write("\nProcess Name:")
f.write(pn)
f.write("\n------------")
f.close()
Thanks :) and please Help :(