程序编写中经常指定,程序已非登录用户权限执行,来实现一些特殊的功能,用户的权限切换可以使用微软的自带工具Runas 实现,然而该工具的使用是交互式的带来的诸多不便。
    VBS可以实现模拟键盘输入和延时相应等功能可以和 Runas配合实现非交互式提权

 
  
  1. dim WshShell,cmd 
  2. cmd="%SystemRoot%\system32\cmd.exe" 
  3. SetWshShell=WScript.CreateObject("WScript.Shell"
  4. WshShell.Run cmd 
  5. WScript.Sleep 100 
  6. WshShell.SendKeys"runas /netonly /user:SUS_LENOVO\liuming1 cmd" 
  7. WshShell.Sleep 200 
  8. WshShell.SendKeys"adlife1983" 
  9. WScript.Sleep 2000 
  10. WshShell.SendKeys"{ENTER}"