Batch file 启动Win7运行方式登录框的批处理或VB脚本?

Batch file 启动Win7运行方式登录框的批处理或VB脚本?,batch-file,vbscript,runas,Batch File,Vbscript,Runas,我正在寻找一个批处理命令或VBscript来执行Shift+右键单击>“以不同用户身份运行”时会弹出一个登录框,标题中只显示“Windows安全性” 我已经搜索了很多地方,最近得到的是命令行中的“runas”,我找到了一个可以执行“以管理员身份运行”的VBscript。但我只想要一个脚本,可以启动上图中的登录框,它与“以不同用户身份运行”相同 谢谢 编辑-我的问题的一些背景: 我有一个批处理文件,我用它通过psexec将软件安装到远程计算机上,并运行一些脚本和其他东西。现在,为了成功运行我的批

我正在寻找一个批处理命令或VBscript来执行Shift+右键单击>“以不同用户身份运行”时会弹出一个登录框,标题中只显示“Windows安全性”

我已经搜索了很多地方,最近得到的是命令行中的“runas”,我找到了一个可以执行“以管理员身份运行”的VBscript。但我只想要一个脚本,可以启动上图中的登录框,它与“以不同用户身份运行”相同

谢谢

编辑-我的问题的一些背景: 我有一个批处理文件,我用它通过psexec将软件安装到远程计算机上,并运行一些脚本和其他东西。现在,为了成功运行我的批处理文件,用户需要在域管理员帐户下运行它。我基本上是想强迫它发生

一开始我试着强迫UAC通过……这很有效!不幸的是,我发现如果本地管理员登录并启动该文件,则该操作将不起作用(它将看到它在本地计算机上已经拥有管理员权限,但在运行psexec时,它在远程计算机上没有权限)

我真的无法通过批处理执行runas,因为我不知道哪个域管理员将运行批处理。我也不希望用户在命令行窗口中输入他们的凭据……我可以告诉他们在bat文件上执行shift+右键单击,但如果可能,我希望避免这样做,因为用户可能会健忘:)

因此,我认为解决我的问题的方法是使用一个脚本,它将完全按照Shift+右键单击>“以不同用户的身份运行”的方式运行


非常感谢您的帮助

Shverb-列出或运行浏览器动词(右键单击菜单)

拖放或在命令行中使用

HelpMsg = vbcrlf & "  ShVerb" & vbcrlf & vbcrlf & "  David Candy 2014" & vbcrlf & vbcrlf & "  Lists or runs an explorer verb (right click menu) on a file or folder" & vbcrlf  & vbcrlf & "    ShVerb <filename> [verb]" & vbcrlf & vbcrlf & "  Used without a verb it lists the verbs available for the file or folder" & vbcrlf & vbcrlf
HelpMsg = HelpMsg & "  The program lists most verbs but only ones above the first separator" & vbcrlf & "  of the menu work when used this way" & vbcrlf & vbcrlf 
HelpMsg = HelpMsg & "  The Properties verb can be used. However the program has to keep running" & vbcrlf & "  to hold the properties dialog open. It keeps running by displaying" & vbcrlf & "  a message box." 
Set objShell = CreateObject("Shell.Application")
Set Ag = WScript.Arguments 
set WshShell = WScript.CreateObject("WScript.Shell") 
Set fso = CreateObject("Scripting.FileSystemObject")

    If Ag.count = 0 then 
        wscript.echo "  ShVerb - No file specified"
        wscript.echo HelpMsg 
        wscript.quit
    Else If Ag.count = 1 then 
        If LCase(Replace(Ag(0),"-", "/")) = "/h" or Replace(Ag(0),"-", "/") = "/?" then 
            wscript.echo HelpMsg 
            wscript.quit
        End If
    ElseIf Ag.count > 2 then 
        wscript.echo vbcrlf & "  ShVerb - To many parameters" & vbcrlf & "  Use quotes around filenames and verbs containing spaces"  & vbcrlf
        wscript.echo HelpMsg 
        wscript.quit
    End If

    If fso.DriveExists(Ag(0)) = True then
        Set objFolder = objShell.Namespace(fso.GetFileName(Ag(0)))
'       Set objFolderItem = objFolder.ParseName(fso.GetFileName(Ag(0)))
        Set objFolderItem = objFolder.self
        msgbox ag(0)
    ElseIf fso.FolderExists(Ag(0)) = True then
        Set objFolder = objShell.Namespace(fso.GetParentFolderName(Ag(0)))
        Set objFolderItem = objFolder.ParseName(fso.GetFileName(Ag(0)))
    ElseIf fso.fileExists(Ag(0)) = True then
        Set objFolder = objShell.Namespace(fso.GetParentFolderName(Ag(0)))
        Set objFolderItem = objFolder.ParseName(fso.GetFileName(Ag(0)))
    Else
        wscript.echo "  ShVerb - " & Ag(0) & " not found"
        wscript.echo HelpMsg 
        wscript.quit
    End If

    Set objVerbs = objFolderItem.Verbs

    'If only one argument list verbs for that item

    If Ag.count = 1 then
        For Each cmd in objFolderItem.Verbs
            If len(cmd) <> 0 then CmdList = CmdList & vbcrlf & replace(cmd.name, "&", "") 
        Next
        wscript.echo mid(CmdList, 2)

    'If two arguments do verbs for that item

    ElseIf Ag.count = 2 then
        For Each cmd in objFolderItem.Verbs
            If lcase(replace(cmd, "&", "")) = LCase(Ag(1)) then 
                wscript.echo Cmd.doit 
                Exit For
            End If
        Next
    'Properties is special cased. Script has to stay running for Properties dialog to show.
        If Lcase(Ag(1)) = "properties" then
            WSHShell.AppActivate(ObjFolderItem.Name & " Properties")
            msgbox "This message box has to stay open to keep the " & ObjFolderItem.Name & " Properties dialog open."
        End If  
    End If
End If

它有内置的帮助。前三行是帮助文件

  ShVerb

  Lists or runs an explorer verb (right click menu) on a file or folder


    ShVerb <filename> [verb]


  Used without a verb it lists the verbs available for the file or folder


  The program lists most verbs but only ones above the first separator

  of the menu work when used this way


  The Properties verb can be used. However the program has to keep running

  to hold the properties dialog open. It keeps running by displaying

  a message box.
ShVerb
列出或运行文件或文件夹上的资源管理器谓词(右键单击菜单)
动词[动词]
不带动词使用它列出可用于文件或文件夹的动词
该程序列出了大多数动词,但仅在第一个分隔符上方列出
使用这种方式时,菜单的所有部分都会起作用
可以使用Properties动词。然而,程序必须保持运行
保持“属性”对话框处于打开状态。它通过显示来保持运行
消息框。
你必须在远程系统上运行它


但这两个命令行工具允许输入密码。正如我所展示的,您可以自动输入用户名。

Runas/user:%userdomain%\%username%“notepad\“my file.txt\”管理员将被提示输入密码。密码就像对话框一样隐藏在cmd提示符中。Runas/user:%userdomain%\%username%“notepad\“my file.txt\”这是要求用户在cmd行中输入他们的凭据。它不会像图中那样弹出登录框。希望这是有意义的,为此,我很感激。不幸的是,我甚至不能解释VBscript的功能,我无法让它运行。对于第二个,我也无法运行它。也许我是个新手,在理解你的答案之前,我需要对这个话题进行更多的研究。再次感谢。谢谢你的回复。我所知道的唯一相关动词是“runas”,但它与UAC有关。我不希望自动填充用户名。我想要一个脚本,我可以放在我的批处理文件的顶部,就像我在OP中链接的“batch-get-admin”脚本一样。唯一的区别是,它没有提升bat文件,我希望它弹出一个登录框,如图所示。
  ShVerb

  Lists or runs an explorer verb (right click menu) on a file or folder


    ShVerb <filename> [verb]


  Used without a verb it lists the verbs available for the file or folder


  The program lists most verbs but only ones above the first separator

  of the menu work when used this way


  The Properties verb can be used. However the program has to keep running

  to hold the properties dialog open. It keeps running by displaying

  a message box.