windows windows批处理文件使用用户名和密码调用远程可执行文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2658892/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
windows batch file to call remote executable with username and password
提问by Jake rue
Hi I am trying to get a batch file to call an executable from the server and login. I have a monitoring program that allows me send and execute the script. OK here goes....
嗨,我正在尝试获取批处理文件以从服务器调用可执行文件并登录。我有一个监控程序,允许我发送和执行脚本。好的,这里开始......
//x3400/NTE_test/test.exe /USER:student password
Now this doesn't work. The path is right because when I type it in at the run menu in xp it works. Then I manually login and the script runs. How can I get this to login and run that exe I need it to?
现在这不起作用。路径是正确的,因为当我在 xp 的运行菜单中输入它时,它可以工作。然后我手动登录并运行脚本。我怎样才能让它登录并运行我需要的那个exe?
Part 2: Some of the machines have already logged in with the password saved (done manually). Should I have a command to first clear that password then login?
第 2 部分:一些机器已经使用保存的密码登录(手动完成)。我应该有一个命令来先清除密码然后登录吗?
Thanks for any replies, I appreciate the help
感谢您的回复,感谢您的帮助
Jake
Hyman
回答by Michael Burr
(note: this question probably belongs on serverfault.com or superuser.com)
(注意:这个问题可能属于 serverfault.com 或 superuser.com)
If the login that needs to happen is the login for the network share, you can have your script do that using the net use command:
如果需要进行的登录是网络共享的登录,您可以使用 net use 命令让您的脚本执行此操作:
net use //x3400/NTE_test /USER:student password
//x3400/NTE_test/test.exe
If the login is something specific to the ``test.exe` program, then you'll have to find out from its documentation how to pass credentials on the command line.
如果登录是特定于“test.exe”程序的,那么您必须从其文档中找出如何在命令行上传递凭据。
In either case, you need to consider the security implications of having a user's password in a script. If the user is has an account with the same name and password on the x3400
server as on the machine he's running on (or if the x3400 machine is in the same domain as his machine), there should be no need for him to provide credentials. This might be a better way to handle the password.
无论哪种情况,您都需要考虑在脚本中包含用户密码的安全隐患。如果用户在x3400
服务器上的帐户与他正在运行的机器上的名称和密码相同(或者如果 x3400 机器与他的机器在同一个域中),他应该不需要提供凭据。这可能是处理密码的更好方法。