中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-09-14 16:27
47,812 topics / 349,917 posts / today 0 new / 48,268 members
DOS批处理 & 脚本技术(批处理室) » [Tutorial] [Update] Treat any executable file (including batch files) as a service
Printable Version  69,121 / 262
Floor1 asbai Posted 2006-06-22 14:18
高级用户 Posts 252 Credits 653
■Note■ Someone actually added me on MSN to ask the difference between this tool and the SC command under XP. It's really frustrating.

Here's the clarification: First, a Windows service is not an ordinary executable program. For an application to become a service, it must call the standard Windows Service API according to the contract and interact correctly with the Windows Service Manager. For details, refer to:
http://msdn.microsoft.com/en-us/library/ms681921(VS.85).aspx and
http://msdn.microsoft.com/en-us/library/ms685967(VS.85).aspx. The detailed API reference is at: http://msdn.microsoft.com/en-us/library/ms685942(VS.85).aspx.

That is, the function of the SC command is to install, delete, start, and stop a service. While the function of runassrv is to turn any non-service program into a service.

If this is still not clear, try using SC to add a certain batch file or notepad.exe as a service and see what happens.


≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
New content in version 1.1.0.628:

■ All Actions (such as: add / remove, etc.) do not need to add a prefix anymore.
■ New pause / continue operations.
■ From now on, a runassrv service can concurrently run multiple applications specified by /cmdline.
■ runassrv.exe itself does not need to be placed in the system search path.
■ New control operation to send a control code to the specified service.
■ New listsrv operation to list all services and drivers, supporting many filtering conditions.
■ New -logfile and -loglevel options, with log recording function.
■ New -unstoppable option, the system service manager will refuse to stop a service installed with this option.
■ Memory contraction strategy, typically with memory overhead less than 300KB.
■ Solved the problem that the start / stop command is invalid on some systems.

≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
A small thing written a few years ago, for everyone's amusement~

Run As Service

A tool to run any executable file (including batch files and scripts) as a system service

≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
Introduction:

■ Run any executable file as a system service.
■ Originally mainly for porting some Linux daemons; can also be used to start any application and maintenance scripts.
■ Runs quietly, unless the Interactive mode is specified, no windows will pop up.
■ No need to log in, it runs automatically after the system starts, without waiting for the user to log in.
■ As a side function, it supports starting, stopping, and deleting any system service.
■ Completely take over the instructions of the system service manager (start, stop, etc.). After the running program terminates, it automatically submits the status to the service manager and exits by itself, without resident memory.

≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
Help screen:



≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
Simple Chinese help:



≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
Copyright: Free software; the author is not responsible for anything. You can use it for any purpose, as long as you don't do bad things

≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
Contact the author: http://www.cn-dos.net/forum or asbai@msn.com

Try to contact via the forum or email for things. But if you like playing StarCraft and are a noob with the same hand speed as me (no more than 100), welcome to add my MSN ^_^

[ Last edited by asbai on 2008-6-3 at 01:33 PM ]

Attachments
runassrv.rar (115.34 KiB)
Floor2 ebfoo Posted 2006-06-22 23:44
初级用户 Posts 9 Credits 31 From cs
What a remarkable person!
Received it first.
Thanks
Floor3 Cappuccin0 Posted 2006-06-23 00:22
新手上路 Posts 7 Credits 9
Saw a post on DRL but didn't have permission to download, so I came here~ By the way, I want to ask the楼主 whether the process of this program will be terminated in the Task Manager? That is, register it as an unstoppable service.
Floor4 asbai Posted 2006-06-23 01:52
高级用户 Posts 252 Credits 653
Originally posted by Cappuccin0 at 2006-6-23 00:22:
Saw a post on DRL but didn't have permission to download, so I came here~~
By the way, I want to ask the LZ whether this program's process will be terminated in the Task Manager? That is, registered as that unstoppable ...


Hehe, what the hell is DRL? When making it, it was written as unpauseble, but not unstoppable. There's no such option either, because I really can't think of what use this option has.
Floor5 Wengier Posted 2006-06-23 02:30
系统支持 Posts 10,521 Credits 27,736
I tried it and found that asbai's programming level is really good. However, I found that both /add and /remove can be used, while /start and /stop sometimes can't be used normally (such as using net start and net stop can). For example:

C:\>runassrv /stop /name:"MySQL"

=======================================================================
Run As Service Ver 1.0.0.3 by BaiYang / 2004, Freeware
=======================================================================

[APPLICATION ERROR] 9 :: CSrvApp::_StopSrv() - unable stop the service.
service name = MySQL
error number = 0
error description = The operation completed successfully.

C:\>net stop MySQL
The MySQL service is stopping..
The MySQL service was stopped successfully.


C:\>
Floor6 ebing Posted 2006-06-23 09:48
初级用户 Posts 12 Credits 130
Learned and saved, thank you!
Floor7 asbai Posted 2006-06-23 15:31
高级用户 Posts 252 Credits 653
Originally posted by Wengier at 2006-6-23 02:30:
Tried it and found that asbai's programming level is indeed quite good. However, found that both /add and /remove can be used, while /start and /stop sometimes cannot be used normally (such as using net start and net stop then can be used). For example..


Can you trouble Brother Wengier to give a step to reproduce the fault? Actually, the original text has some special symbols like "" which may not be properly displayed, but the translation for the rest is as above. And the last sentence "能不能麻烦Wengier兄给个故障重现的步骤?;" is translated to "Can you trouble Brother Wengier to give a step to reproduce the fault? "
Floor8 electronixtar Posted 2006-06-23 15:47
铂金会员 Posts 2,672 Credits 7,493
Floor9 Wengier Posted 2006-06-23 23:09
系统支持 Posts 10,521 Credits 27,736
Originally posted by asbai at 2006-6-23 03:31 PM:


Could you please ask Brother Wengier to give a step-by-step procedure to reproduce the fault? ;)


The reproduction method is actually in floor 5. Of course, "MySQL" can be changed to other similar existing services.
Floor10 asbai Posted 2006-06-24 05:53
高级用户 Posts 252 Credits 653
Originally posted by Wengier at 2006-6-23 23:09:

There is actually a method to reproduce in floor 5. Of course, the "MySQL" there can be changed to other similar existing services.


sorry, I thought that what you said: "It seems that sometimes it can't be used normally" refers to that it occurs under certain specific environments and according to specific procedures.

I'll go and have a look now.
Floor11 asbai Posted 2006-06-24 12:52
高级用户 Posts 252 Credits 653
Which version of Windows are you using, Brother Wengier?
Floor12 Wengier Posted 2006-06-24 14:05
系统支持 Posts 10,521 Credits 27,736
Windows XP SP2 English version
Floor13 zhweller Posted 2006-06-25 13:26
新手上路 Posts 1 Credits 2
Been looking for it for a long time!!!
Floor14 electronixtar Posted 2006-06-25 15:11
铂金会员 Posts 2,672 Credits 7,493
Floor15 asbai Posted 2006-06-28 02:03
高级用户 Posts 252 Credits 653
Originally posted by electronixtar at 2006-6-25 15:11:
hoho~~~ Saw the original post

http://www.et8.net/bbs/showthread.php?t=763159


Brother electronixtar made a mistake? Take a closer look, this is the original post, ^_^
1 2 3 418  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023