Create a Windows service using Instsrv.exe and Srvany.exe under 64-bit Windows

Source: Internet
Author: User

Create a Windows service using Instsrv.exe and Srvany.exe under 64-bit Windows

Under 32-bit Windows, including Windows7,windows XP and Windows 2003, you can use Instsrv.exe and Srvany.exe to create custom Windows services. For example, we have a bat file that launches the specified program as a service, and it is not possible to do so with a generic tool, while using the instsrv that is in Windows Toolkit with the Windows 2003 Resource Kit.

Detailed usage here is no longer specific, the simple point is to use INSTSRV to register the corresponding Srvany as a service, and then add the corresponding application and Appdirectory parameters in the registry for Srvany to start our corresponding services. As shown in the following code://Generate the corresponding program as a service

123456789 set s32=%windir%\system32%s32%\instsrv.exe %service_name% %s32%\srvany.exe //在注册表中更新相应的参数echo Windows Registry Editor Version 5.00> %reg_file%echo >> %reg_file%echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\%service_name%\Parameters] >> %reg_file%echo "Application"="%prog_path%\\%prog_name%" >> %reg_file%//程序地址echo "AppDirectory"="%prog_path%" >> %reg_file%//程序目录

The above code will work correctly on all 32-bit systems, including Windows 2000. However, under 64-bit Windows, the above code is invalid. Will report one of the following errors:

1 Unable to find the file at the given path

After careful examination of the parameters, it is determined that this is caused by a system cause.

The final reason is that the instsrv and srvany we use are 32-bit, and Windows now has no corresponding 64-bit counterpart tools to publish. And the program itself is no problem, the problem is that we put instsrv and Srvany to Windows/system32 front, and in 64-bit system, here should be stored 64-bit program, so the final solution is very simple. We just need to copy the two programs to the place where the 32-bit program should be placed, such as the Windows/syswow64 directory, and that's it. The original steps and procedures do not need to be changed at all. INSTSRV will automatically find the program that should have been placed under System32, which is now placed in the SYSWOW64 directory.

A simple workaround is to copy the INSTSRV and Srvany programs in the WINDOWS/SYSWOW64 directory, which is equivalent to having a program in both System32 and SysWow64, which solves the problem. The underlying reason, perhaps only Microsoft can explain, in short, under the 64-bit system, 32-bit program is not placed under the System32 program, and it should be accessed by the System32 directory is mapped to the SYSWOW64 directory, At run time, the system automatically maps the corresponding SYSWOW64 directory to the System32 considered by the program.
Reference Document: Http://en.wikipedia.org/wiki/WoW64

Reprint please indicate source: I Flym
This address: http://www.iflym.com/index.php/computer-use/201205020001.html

To create a Windows service using Instsrv.exe and Srvany.exe under 64-bit Windows

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.