2014-05-20 33 views
0

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

我已经搜索到了最广泛和最接近的我是从命令行的“runas”,我找到了一个VBscript可以做“以管理员身份运行”。但我只想要一个脚本,将启动一个登录框如上面的图片,这是一样的“运行方式不同的用户”

感谢

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

起初我试着迫使UAC通过this beautiful script来......这很好!不幸的是,我发现如果本地管理员登录并启动该文件将无法工作(它会看到它已经在本地计算机上拥有管理权限,但它在远程计算机上运行时没有权限PSEXEC)。

我真的不能通过批处理做一个runas,因为我不知道域管理员将要运行批处理。我也宁愿不让用户在命令行窗口中输入他们的凭据...我可以告诉他们做shift +右键单击bat文件,但是如果可能,我想避免这种情况,因为用户可能会忘记:)

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

任何帮助是极大的赞赏

回答

0

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 

wmic /node"@%userprofile%\desktop\ComputerName.txt" /user:username /password:password /failfast:on process call create c:\somefile.bat 
+0

Runas/user:%userdomain%\%username%“notepad \”my file.txt \“”管理员将被提示输入他们的密码。密码与对话框一样隐藏在cmd提示符中。 – user3654095

+0

Runas/user:%userdomain%\%username%“notepad \”我的file.txt \“”这是要求用户将他们的凭据输入cmd行。它不会像图片中弹出登录框。希望有道理 – stilljammin313

+0

我已经向您展示了三种解决问题的方法。 – user3654095

0

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

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. 

您必须在远程系统上运行它。

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

+0

感谢您的回复。我知道唯一相关的动词是“run as”,但只是随UAC升高。我不想让用户名自动填充。我想要一个脚本,可以将其放在批处理文件的顶部,该文件的操作方式与我在OP中链接的“批量获取管理”脚本相同。唯一的区别是,我不希望它升高bat文件,而是希望它弹出一个登录框,如我所描绘的。 – stilljammin313