By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,271 Members | 1,722 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,271 IT Pros & Developers. It's quick & easy.

python script under windows

P: n/a
Hello

I run python script on another computer and want to "survive" that
script after my logout. the script also uses drive mapping to network drive.

Can you help me ? Or better is there some info for unix person how
to survive with python on windows ;-)

thanks,
jan gregor
Sep 9 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Hi Jan,

Unfortunately you will have to register it as a service. I am almost
certain there is no other way to do it. However, setting up an
executable as a true Windows Service is extremely tedious. You can try
this utility that I use. You can get it here:
http://www.seritt.org/pub/srvinst13b.exe. I'm probably not supposed to
distribute it, but the site and owners that used to host it have gone
belly up best that I can tell. As with anything, use it at your own
risk. I found it as freeware a few months back.

If you want a decent cheap solution, FireDaemon is pretty good. I think
it's like 30USD but it does a great job and adds a few extra features.

HTH,

Harlin Seritt
Internet Villa: www.seritt.org

Sep 9 '05 #2

P: n/a
Jan Gregor wrote:
I run python script on another computer and want to "survive" that
script after my logout.


Start at http://www.python.org/windows/win32/#NTServices.
--
Benji York

Sep 9 '05 #3

P: n/a
Making a Python program into a service isn't all that "tedious".
Get a copy of Mark Hammonds "Python Programming on Win32" which
contains excellent examples on how to do this. I've written
several and after the first one, it is quite easy to do.

-Larry Bates

Harlin Seritt wrote:
Hi Jan,

Unfortunately you will have to register it as a service. I am almost
certain there is no other way to do it. However, setting up an
executable as a true Windows Service is extremely tedious. You can try
this utility that I use. You can get it here:
http://www.seritt.org/pub/srvinst13b.exe. I'm probably not supposed to
distribute it, but the site and owners that used to host it have gone
belly up best that I can tell. As with anything, use it at your own
risk. I found it as freeware a few months back.

If you want a decent cheap solution, FireDaemon is pretty good. I think
it's like 30USD but it does a great job and adds a few extra features.

HTH,

Harlin Seritt
Internet Villa: www.seritt.org

Sep 9 '05 #4

P: n/a
You can use the Task Scheduler to run a script persistently if you
don't need the capabilities of the service framework.

Roger

"Jan Gregor" <gr********@NOSPAM.quick.cz> wrote in message news:df**********@ns.felk.cvut.cz...
Hello

I run python script on another computer and want to "survive" that
script after my logout. the script also uses drive mapping to network drive.

Can you help me ? Or better is there some info for unix person how
to survive with python on windows ;-)

thanks,
jan gregor


----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Sep 9 '05 #5

P: n/a
Jan,

Here's what I did to run a Python script (let's call it myscript.py) as
a service:

1. Install Win2K Resource Kit.

2. Run instsrv to install srvany.exe as a service with the name
myscript:

C:\Program Files\Resource Kit\instsrv myscript "C:\Program
Files\Resource Kit\srvany.exe"

3. Go to Computer Management->Services and make sure myscript is listed
as a service. Also make sure the Startup Type is Automatic.

4. Create a myscript.bat file with the following contents in e.g.
C:\pyscripts:

C:\Python23\python C:\pyscripts\myscript.py

5. Create new registry entries for the new service.
- run regedt32 and go to the
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servic es\myscript entry
- add new key (Edit->Add Key) called Parameters
- add new entry for Parameters key (Edit->Add Value) to set the
Application name => Name should be Application, Type should be
REG_SZ, Value should be path to myscript.bat, i.e.
C:\pyscripts\myscript.bat
- add new entry for Parameters key (Edit->Add Value) to set the working
directory => Name should be AppDir, Type should be
REG_SZ, Value should be path to pyscripts directory, i.e. C:\pyscripts

6. Test starting and stopping the myscript service in Computer
Management->Services.

Sep 9 '05 #6

P: n/a
> Can you help me ? Or better is there some info for unix person how
to survive with python on windows ;-)


Use py2exe to transform your app into a service...

Sep 12 '05 #7

P: n/a
cg
I ran into a similar issue a couple of months back, the solution on
Windows is to run it as a service. It is very simple, you need Mark
Hammond's Win32 extensions. For path you have to use absolute filepath
for all local files and for network drive use the UNC path i.e.
\\servername\folder-filename\ . All these steps will let your machine
running the program survive logouts after a login. If your machine is
part of windows network and there is domain login then in order for it
to work after a machine restart you need to goto the Service panel (in
Control Panel) find the Python service you registered, right-click and
goto its properties, goto the "Log On" panel, select a domain user for
"This account" by clicking the Browse button, note the selected user
has access to windows domain and admin access to that particular
machine. Enter user network password, hit Apply, OK and there u go. All
this requires admin access to machine. You can configure a couple of
things about the service in the Services panel.

The code itself is simple:
#------------------------------------------------------------------
import win32service, win32serviceutil

class MyService(win32serviceutil.ServiceFramework):
"""NT Service."""

_svc_name_ = "MyServiceName"
_svc_display_name_ = "A Little More Descriptive"

def SvcDoRun(self):
#do your stuff here, call your main application code.

def SvcStop(self):
#the following line is not really needed, basically put here
any code that should execute
#before the service stops
self.ReportServiceStatus(win32service.SERVICE_STOP _PENDING)

if __name__ == '__main__':
win32serviceutil.HandleCommandLine(MyService)
#------------------------------------------------------------------
After this if you have python in your path and Win32 extensions
installed, goto command prompt and run:
c:\> MyService.py -startup=auto install

Trying to have your service have Network access after a machine restart
is a bit tricky. This thing works but somehow I feel there is more to
it. If anyone has a better way, please post.

Sep 20 '05 #8

P: n/a
typo, the correct command is:
c:\>python MyService.py -startup=auto install

Sep 21 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.