『楼 主』:
win7中使用runas命令(替代右键“以管理员身份运行”)
使用 LLM 解释/回答一下
在win7中,由于账户控制,使用cmd就不太方便,因为权限问题,比方说最简单的,输入“net start mssqlserver”(开启sql server服务),就会提示“拒绝访问”。最简单的解决办法就是右键选择“以管理员身份运行”,获取权限就够了。
现在发现这样也不方便,就想着是不是有什么命令可以达到这样的效果。查了下,就是“runas”。
在cmd里输入“runas /?”查看帮助,其实我要的只是以管理员账号运行就够了,输入“runas /user:administrator cmd”(用administrator运行cmd),之后会让输入密码,输入密码后报错了 “RUNAS 错误: 无法运行 - cmd 1058: 无法启动服务,原因可能是已被禁用或与其相关联的设备没有启动。”
这个是因为 “Secondary Logo”服务没有启动,这个服务是“在不同凭据下启用启动过程”。直接在cmd中输入services.msc,将服务从禁用改为手动就好了,之后再次输入runas命令,就会弹出新的cmd窗口,且是以administrator账号运行的,权限问题搞定。
In Windows 7, due to User Account Control, using cmd is not very convenient because of permission issues. For example, the simplest thing, entering "net start mssqlserver" (to start the SQL Server service), will prompt "Access is denied". The simplest solution is to right-click and select "Run as administrator" to obtain permissions.
Now I find this is not convenient either, so I thought if there is any command that can achieve this effect. After checking, it's "runas".
Enter "runas /?" in cmd to view the help. Actually, all I need is to run with an administrator account. Enter "runas /user:administrator cmd" (run cmd with administrator), then it will ask for the password. After entering the password, an error occurs: "RUNAS error: Unable to run - cmd 1058: The service cannot be started. The reason could be that it is disabled or there is no associated device started."
This is because the "Secondary Logo" service is not started. This service is "Enable the startup process under different credentials". Directly enter services.msc in cmd, change the service from disabled to manual, then enter the runas command again, and a new cmd window will pop up, and it will run with the administrator account, and the permission issue is solved.
|