Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Automate Runas with SmartCard

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,64395
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Automate Runas with SmartCard
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Automate Runas with SmartCard - 9/19/2008 3:05:36 AM   
  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
 
 
Post #: 1
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Automate Runas with SmartCard Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts