| |
alayanna
Posts: 5
Score: 0
Joined: 8/28/2008
Status: offline
|
I am trying to use a script to automate runas with a smart card. This script works if you don't use the smartcard. Does anyone know why this is not working with a smart card? The only difference I see is that when you don't use a smartcard, the next line is Enter the password for UserName: and if you do use a smartcard, it says: Reading Smartcards.... Using the card reader 1. Enter the PIN: Perhaps the script is sending the password to quicky? On Error Resume Next dim WshShell,oArgs,FSO sUser="UserName"&VBCRLF sPass="Password"&VBCRLF sCmd="Command" set WshShell = CreateObject("WScript.Shell") set WshEnv = WshShell.Environment("Process") WinPath = WshEnv("SystemRoot")&"\System32\runas.exe" set FSO = CreateObject("Scripting.FileSystemObject") rc=WshShell.Run("runas /smartcard /user:" & sUser & " " & CHR(34) & sCmd & CHR(34), 2, FALSE) wscript.echo "runas /smartcard /user:" & sUser & " " & CHR(34) & sCmd & CHR(34) Wscript.Sleep 1000 WshShell.AppActivate(WinPath) WshShell.SendKeys sPass set WshShell=Nothing set oArgs=Nothing set WshEnv=Nothing set FSO=Nothing wscript.quit
|
|