Need Help Modifing a VBS Script

Greeting Experts,
I am in need of some help with existing .vbs script used to excite windows.exe program or utility. Currently I am trying to modify the following script to start windows cmd.exe utility and use the hard-coded username and password in the script its self.  But for some reason, it keeps prompting me for a password instead of using the fixed password located on Line 26. Can someone take and look at this and see what may be wrong…

'Start of Script
'USAGE: cscript|wscript VBRUNAS.VBS airseaforwarder\misrshe kinkado "C:\Program Files\Microsoft Office\Office10\outlook.exe"
'DESC: A RUNAS replacement to take password at a command prompt.
'NOTES: This is meant to be used for local access. If you want to run a command
'across the network as another user, you must add the /NETONLY switch to the RUNAS

On Error Resume Next
dim WshShell,oArgs,FSO


set WshShell = CreateObject("WScript.Shell")
set WshEnv = WshShell.Environment("Process")
WinPath = WshEnv("SystemRoot")&"\System32\runas.exe"
set FSO = CreateObject("Scripting.FileSystemObject")

if FSO.FileExists(winpath) then
'wscript.echo winpath & " " & "verified"
wscript.echo "!! ERROR !!" & VBCRLF & "Can't find or verify " & winpath &"." & VBCRLF & "You must be running Windows 2000 or XP for this script to work."
set WshShell=Nothing
set WshEnv=Nothing
set oArgs=Nothing
set FSO=Nothing
end if
'Use this line for remote file access and comment out the line below
'rc=WshShell.Run("runas /netonly /user:" & sUser & " " & CHR(34) & sCmd & CHR(34), 2, FALSE)

'Use this line for local file access and comment out the above line
rc=WshShell.Run("runas /user:" & sUser & " " & CHR(34) & sCmd & CHR(34), 2, FALSE)

Wscript.Sleep 30 'need to give time for window to open.
WshShell.AppActivate(WinPath) 'make sure we grab the right window to send password to
WshShell.SendKeys sPass 'send the password to the waiting window.

set WshShell=Nothing
set oArgs=Nothing
set WshEnv=Nothing
set FSO=Nothing


'* Usage Subroutine *

Sub Usage()
On Error Resume Next
msg="Usage: cscript|wscript runas.vbs Username Password Command" & VBCRLF & VBCRLF & "You should use the full path where necessary and put long file names or commands" & VBCRLF & "with parameters in quotes" & VBCRLF & VBCRLF &"For example:" & VBCRLF &" cscript runas.vbs domain\admin luckydog e:\scripts\admin.vbs" & VBCRLF & VBCRLF &" cscript runas.vbs domain\admin luckydog " & CHR(34) &"e:\program files\scripts\admin.vbs 1stParameter 2ndParameter" & CHR(34)& VBCRLF & VBCRLF & VBCLRF & "cscript runas.vbs /?|-? will display this message."

wscript.echo msg


end sub
'End of Script 

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Not sure if this is the problem, but the password may be getting lost because of a delay in the window appearing.  I think you can add a wait here:

WshShell.SendKeys sPass, True

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MikeSecurityAuthor Commented:
That solved the problem thanks....
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.