Running batch file through windows service

0 comments
Prerequisite
  • Windows Resource kit.
Install resource kit to C:\RESKIT Directory

Setps to follow:
1.Open text editor and create Autoexnt.bat and include the commands you want to run at startup in this file.

2.Copy Autoexnt.bat file which you just created ,in addition to the Autoexnt.exe,Servmess.dll, and Instexnt.exe files located in the C:\RESKIT to the %SystemRoot%\System32 folder on your computer.

3.Now to install the service use following command and run them in command prompt.
instexnt install
To view the installation processes running on the desktop, use interactive switch as follow
instexnt install \interactive

You should then receive the following message:
CreateService AutoExNT SUCCESS with InterActive Flag turned OFF

NOTE: If you use the /interactive switch, any users who log on locally are able to stop the processes from running.

Testing the AutoExNT Service
To test the AutoExNT service, log on to your computer with an account that has administrator credentials, type net start autoexnt at a command prompt, and then press ENTER. The Autoexnt.bat file should run in an MS-DOS window.

To make the AutoExNT service run at startup:
Open computer management and expand services. Locate the AutoExNT serive and make it as automatic.

Launching Any program as windows service Using Windows resource kit

0 comments
Steps For Launching the any program as windows service

prerequisite
1.Windows Resource kit.
Install resource kit to C:\RESKIT Directory

1.At a MS-DOS command prompt(running CMD.EXE), type the following command:

C:\RESKIT\INSTSRV.EXE My_Service_Name C:\RESKIT\SRVANY.EXE

NOTE: To verify that the service was created correctly, check the registry to verify that the ImagePath value under
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\My_Service_Name
is set to point to SRVANY.EXE. If this is not set correctly, the service will stop shortly after it starts and return an Event ID 7000 "The service name failed to start."

2.Run Registry Editor (Regedt32.exe)and locate the following subkey:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\My_Service_Name

3.From the Edit menu, click Add Key. Type the following and click OK:
Key Name: Parameters

4.Select the Parameters key.

5.From the Edit menu, click Add String Value. Type the following and click OK:
Value Name: Application
Data Type : REG_SZ
String : path\application.ext

where "path\application.ext" is the drive and full path to the application executable including the extension

6.From the Edit menu, click Add String Value. Type the following and click OK:
Value Name: AppDirectory
Data Type : REG_SZ
String : path

where "path" is the drive and full path to directory where the application application resides

7.Close Registry Editor.

8.Starting / Stopping service
- From the Services applet in Control Panel
- From a MS-DOS command prompt, type the following:
NET START My_Service_Name
NET STOP My_Service_Name

9.Testing whether My_Service_Name is started or not
Open task manager. Go to process tab.
When service is started then there should be two processes running "srvany.exe" and "My_Service_Name.exe"

10.Removing service
Open command prompt and run command

C:\RESKIT\INSTSRV My_Service_Name remove