I m using win XP Professional and python 2.6
i hv written 2 programs. "process.py " and "Reg_write_read .py". I have created the exe of both (through py2exe),"Reg_wr ite_read.py" program writes a value in registry through which the process.exe(whi ch is located in C:/) executes on computer restart. But when i Restart my computer. the "process.exe.lo g" 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".
after this i created exe with pyinstaller (using python 2.5), in this case although i m not getting error but again the exe is not running.
. 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 also put the exe in start up folder in win xp
I dont understand what is wrong..Kindly Suggest..Thanks in advance.
THE CODE IS BELOW
Thanks and please Help
i hv written 2 programs. "process.py " and "Reg_write_read .py". I have created the exe of both (through py2exe),"Reg_wr ite_read.py" program writes a value in registry through which the process.exe(whi ch is located in C:/) executes on computer restart. But when i Restart my computer. the "process.exe.lo g" 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".
after this i created exe with pyinstaller (using python 2.5), in this case although i m not getting error but again the exe is not running.
. 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 also put the exe in start up folder in win xp
I dont understand what is wrong..Kindly Suggest..Thanks in advance.
THE CODE IS BELOW
Code:
--------------------- #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)
Code:
-------------------------------
#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()