473,399 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

python script under windows

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
8 3222
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
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
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
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
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
> 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
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
typo, the correct command is:
c:\>python MyService.py -startup=auto install

Sep 21 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jorgen Grahn | last post by:
I couldn't think of a good solution, and it's hard to Google for... I write python command-line programs under Win2k, and I use the bash shell from Cygwin. I cannot use Cygwin's python package...
33
by: Darren Dale | last post by:
I love the language. I love the community. My only complaint is that Python for Windows is built with Visual Studio. It is too difficult to build python, or a module, from source. This is what...
5
by: Fuzzyman | last post by:
Python 2.4 is built with Microsoft Visiual C++ 7. This means that it uses msvcr7.dll, which *isn't* a standard part of the windows operating system. This means that if you build a windows installer...
10
by: Andrew Dalke | last post by:
Is there an author index for the new version of the Python cookbook? As a contributor I got my comp version delivered today and my ego wanted some gratification. I couldn't find my entries. ...
35
by: Michael Kearns | last post by:
I've been using python to write a simple 'launcher' for one of our Java applications for quite a while now. I recently updated it to use python 2.4, and all seemed well. Today, one of my...
17
by: Paul Rubin | last post by:
Dumb question from a Windows ignoramus: I find myself needing to write a Python app (call it myapp.py) that uses tkinter, which as it happens has to be used under (ugh) Windows. That's Windows...
3
by: diffuser78 | last post by:
I am a newbie in Python and want your help in writing python script. I have to remotely shut the windows px from linux box. I run OpenSSH on windows PC. I remotely connect it from Linux box using...
16
by: diffuser78 | last post by:
I want to write a python program and call OS specific commands in it. So basically, instead of typing in on the command line argument I want to have it in a python program and let it do the action....
15
by: kyosohma | last post by:
Hi, I am trying to get a small group of volunteers together to create Windows binaries for any Python extension developer that needs them, much like the package/extension builders who volunteer...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.