windows - 如何在Windows XP Embedded(未安装Sc.exe)上创建服务?

标签 windows service embedded

如何在Windows XP Embedded(未安装Sc.exe)上创建服务?

最佳答案

你可以尝试使用VBScript,我从here找到了这段代码,OP 说它工作得很好,所以也许值得尝试。

' Connect to WMI. 
set objServices = GetObjecT("winmgmts:root\cimv2") 

' Obtain the definition of the Win32_Service class. 
Set objService = objServices.Get("Win32_Service") 

' Obtain an InParameters object specific to the Win32_Service.Create method. 
Set objInParam = objService.Methods_("Create").inParameters.SpawnInstance_() 

' Add the input parameters. 
objInParam.Properties_.item("Name") = "GPServer" '< - Service Name 
objInParam.Properties_.item("DisplayName") = "GPServer" '< - Display Name, what you see in the Services control panel 
objInParam.Properties_.item("PathName") = "c:\Server\srvany.exe" '< - Path and Command Line of the executable 
objInParam.Properties_.item("ServiceType") = 16 
objInParam.Properties_.item("ErrorControl") = 0 
objInParam.Properties_.item("StartMode") = "Manual" 
objInParam.Properties_.item("DesktopInteract") = True
'objInParam.Properties_.item("StartName") = ".\Administrator" '< - If null, will run as Local System 
'objInParam.Properties_.item("StartPassword") = "YourPassword" '< - Only populate if the SatrtName param is populated 

'More parameters and return statuses are listed in MSDN: "Create Method of the Win32_Service Class" 


' Execute the method and obtain the return status. 
' The OutParameters object in objOutParams is created by the provider. 
Set objOutParams = objService.ExecMethod_("Create", objInParam) 
wscript.echo objOutParams.ReturnValue

关于windows - 如何在Windows XP Embedded(未安装Sc.exe)上创建服务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14459913/

相关文章:

android 持续轮询...如何?

embedded - trace32 - 将多个地址范围的内存转储到单个二进制文件

sql - Windows 应用程序是否容易受到 SQL 注入(inject)攻击

android - 两个应用程序之间的 AIDL 接口(interface)

service - Jenkins windows slave 服务不与桌面交互

c - 我如何知道嵌入式系统项目是否正在使用嵌入式操作系统?

在嵌入式 C 中将 char 转换为 float

c++ - 从 C++ 中的文本框中复制文本

java - 尝试创建批处理文件来运行 Java 程序时无法找到或加载主类

windows - 如何在Windows中使用nodejs安装node-mongodb-native