您有任何解决方案可将本地用户切换为管理员,以用于通过批处理文件启动服务 [英] have u any solution to switch local user to administrator to use to start services through batch file

查看:170
本文介绍了您有任何解决方案可将本地用户切换为管理员,以用于通过批处理文件启动服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨...
较早前,我通过命令行[runas/user:administrator cmd]使用它,然后一遍一遍地使用密码和服务,这非常耗时,如果我们有admin用户ID和密码,可以将本地用户切换为admin,那么您对批处理命令有任何想法吗?用户使用(启动/停止/重新启动)services.msc或系统的任何其他工具..
我无法通过批处理文件命令传递密码以用作管理员服务.

hi...
earlier i use it through command line[runas /user:administrator cmd]and then use password and services one by one its time consuming, have u any idea regarding batch command if we have admin user ID and password to switch as local user to admin user to (start/stop/restart )services.msc or any other tools..of system
i am unable to pass the password to use as services of admin through batch file command

推荐答案

当然可以.

最简单的事情是使用Microsoft应用程序SC.EXE,它只是一个与服务控制器进行通信的面向控制台的前端,因此在批处理文件中易于使用.
请参阅 http://www.microsoft.com /resources/documentation/windows/xp/all/proddocs/en-us/sc.mspx?mfr=true [ http://en.wikipedia.org/wiki/Windows_Resource_Kit [ ^ ]以及本文底部对Microsoft下载页面的引用.

通常,您可以使用服务控制器,尤其是使用此实用程序来控制已安装的服务.

另外,您可以嵌入使用Service Controller API以描述的方式控制服务的功能.实际上,您可以在与服务应用程序相同的应用程序中实现此类功能.流程的瞬间可以确定它是作为服务运行还是以交互方式运行.如果这是交互式运行,则该过程可以查看命令行(甚至从特殊的仅用于交互式的UI中获取命令)并在注册的服务上执行所需的操作.我不会为您提供任何更多细节,只是因为您没有共享平台和语言.我只在.NET上做过.另外,似乎您宁愿寻找一种基于SC.EXE的解决方案.

—SA
Of course you can do it.

Most simple thing is using the Microsoft application SC.EXE which simply a console-oriented front-end communicating with the Service Controller, so it''s easy to use in the batch files.
See http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/sc.mspx?mfr=true[^].

This utility is available in the Resource Kit, see http://en.wikipedia.org/wiki/Windows_Resource_Kit[^] and the references to Microsoft download pages at the bottom of this article.

You can control installed services using the Service Controller in general and this utility in particular.

Also, you can embed the capabilities of controlling the service the way you described using Service Controller API. Actually you can implement such functionality in the same application as your service application. An instant of the process can determine if it is running as a service or interactively. If this is an interactive run, the process can look at command line (or even get a command from a special interactive-only UI) and perform the required operation on the registered service. I''m not giving you any further detail just because you did not share your platform and language. I did it only on .NET. Also, it seems to be you rather look for a solution like the one based on SC.EXE.

—SA


这篇关于您有任何解决方案可将本地用户切换为管理员,以用于通过批处理文件启动服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆