Hello All,

I already posted this in the forums but in a different way as the runas credentials and qtp credentials are different.
I had this code to run as restricted user and the script runs fine without any errors. but i dont get the output as in the code

Please advise where i went wrong. Appreciate your help in advance.

Thank you

'Option Explicit
Dim WshShell
Dim fso
Dim WshNetwork
Dim oDic
Dim objArgs
Dim oProcessEnv

Const USER = "xxxx"
Const PASS1 = "xxxxxxx"
'Const USER = "UserName"
'Const PASS = "Password"
Const WSNAME_COMMANDLINE = "C:\windows\system32\wscript.exe C:\Patches.vbs > c:\Patches1230.txt" 'MyScriptFile = your original VBS
Set fso = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("WScript.Shell")
Set WshNetwork = CreateObject("WScript.Network")
Set oDic = CreateObject("Scripting.Dictionary")
'Set objArgs = WScript.Arguments
Set oProcessEnv = WshShell.Environment("PROCESS")
Dim sPathToRunAs, iReturnCode
sPathToRunAs = oProcessEnv("SystemRoot")&"\System32\runas.exe "
if Not fso.FileExists(sPathToRunAs) Then : WScript.Quit(1) 'Can't find RunAs
iReturnCode=WshShell.Run("runas /user:" & USER & " " & CHR(34) & WSNAME_COMMANDLINE & CHR(34), 2, FALSE)
Wait(5) ' Time for window to open.
WshShell.AppActivate(sPathToRunAs)' Activate the Window
WSHShell.SendKeys PASS1 & "~" ' Send the password