Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 12th, 2012, 10:10 AM
pyjax pyjax is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2012
Posts: 3 pyjax User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 m 56 sec
Reputation Power: 0
Running a python script by opening a .exe

Is it possible to write a python script that will execute anytime someones opens a certain .exe file? Basically I have written a script that opens a text file containing warning and disclaimer information, and I need it to open on the users screen anytime he/she opens this particular program. Any help in the write direction would be appreciated.

Reply With Quote
  #2  
Old July 12th, 2012, 05:02 PM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,353 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 8 h 3 m 36 sec
Reputation Power: 383
What do you mean?

Do you want a notice to appear if this code executes?
open('certain.exe')
For this to work you'd need serious file system support---the file system would need the ability to call back your code when it opens files.

Do you need the notice to appear if someone runs it?
shellPrompt$ certain.exe
If you wrote the certain program you could modify it to display your notice. If you don't have the certain source then instead you could include certain.exe as data in your own program, which would then display the notice, write the program as a temporary file, and then fork to it.
__________________
[code]Code tags[/code] are essential for python code!

Reply With Quote
  #3  
Old July 13th, 2012, 09:46 AM
Quackajack Quackajack is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2012
Posts: 35 Quackajack User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 55 m 6 sec
Reputation Power: 1
I'll assume the obvious answer of change the shortcut to a batch file that displays the warning message before running the exe is not possible.

You can find out a list of running processes using a WMI query. For example if the WQL SELECT * FROM Win32_Process WHERE Description = 'notepad.exe' this will return all the occurrances of notepad or nothing if notepad is not running.

I put a some information on using WMI with Python on my blog(quackajack.wordpress.com) if that helps.

If you want to get information on processes being started, I'm not sure that is going to be possible without elevating permissions. I saw an article on hooking into the API for process creation on The Code Project but it is not going to be easy to replicate in Python.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Running a python script by opening a .exe

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap