如何在一行中完成RUNAS命令 [英] How to complete the RUNAS command in one line

查看:88
本文介绍了如何在一行中完成RUNAS命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个堆栈溢出"问题提出了一个看起来像它应该工作的命令,但它似乎不起作用(尽管该答案现在已删除):

This Stack Overflow question suggests a command which looks as if it should work, but it doesn't (that answer is deleted now, though):

用于在Windows 7上以其他用户身份运行并包含密码的单行命令

命令为:

echo PaSsWoRd | runas /user:Administrator cmd

但是它说:

用户名未知或密码错误.

unknown user name or bad password.

细节绝对正确.例如,如果我要运行:

The details are definitely correct though. For example, if I was to run:

runas /user:Administrator

...然后在下一行,如果我键入PaSsWoRd,它将没有问题.

...and on the next line, if I typed in PaSsWoRd, it would work no problem.

推荐答案

runas命令不允许在其命令行上输入密码.这是设计使然(也是您无法通过密码将密码作为输入的原因).雷蒙德·陈(Raymond Chen)很好地说:

The runas command does not allow a password on its command line. This is by design (and also the reason you cannot pipe a password to it as input). Raymond Chen says it nicely:

RunAs程序要求您手动键入密码.为什么它在命令行上不接受密码?

The RunAs program demands that you type the password manually. Why doesn't it accept a password on the command line?

这是一个有意识的决定.如果可以在命令行上通过密码,人们将开始将密码嵌入批处理文件和登录脚本中,这可笑地是不安全的.

This was a conscious decision. If it were possible to pass the password on the command line, people would start embedding passwords into batch files and logon scripts, which is laughably insecure.

换句话说,缺少该功能以消除不安全使用该功能的诱惑.

In other words, the feature is missing to remove the temptation to use the feature insecurely.

这篇关于如何在一行中完成RUNAS命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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