Automatically respond to runas from batch file

后端 未结 1 1210
予麋鹿
予麋鹿 2020-12-03 13:01

I\'m trying to get a batch file to automatically enter the password into the \"runas\" program, but I can\'t get it to work. Here\'s my batch file so far:

ec         


        
相关标签:
1条回答
  • 2020-12-03 13:30

    The Batch-JScript hybrid script below do what you want. Save it with .bat extension.

    @if (@CodeSection == @Batch) @then
    @echo off
    start "" runas /user:testuser c:/path/to/my/program.exe
    CScript //nologo //E:JScript "%~F0"
    goto :EOF
    @end
    WScript.CreateObject("WScript.Shell").SendKeys("password{ENTER}");
    

    For further details, see this post

    0 讨论(0)
提交回复
热议问题