
I am running the code from local windows machine using command "C:\Users\abc\Desktop\secureCRT\Test>securecrt.exe /SCRIPT "C:\Users\abc\Desktop\secureCRT\Test\oswatch_drv.vbs" /ARG "ls -l" /S "" OShell.Run "cscript.exe //NoLogo """ & WScript.Hi, We have written a VB program to access secureCrt shell and execute the command in the jump server. '= Now restart with CScript and terminate this instance '= Add the argument to the list, enclosing it in quotesĪrgList = argList & " """ & (IX) & """" '= Get the arguments on the command line and build an argument listįor IX = 0 to - 1 If InStr( LCase( WScript.FullName ), "cscript.exe" ) = 0 Then Set oShell = CreateObject("WScript.Shell") '= then run using CScript and terminate this instance. '= Check to make sure we are running under CScript, if not restart '= Run on creation of the cCONSOLE object, checks for cScript operation

'= switches to CScript if the script has been started in WScript. '= to write to and read from the CSCript console.

'= This class provides automatic switch to CScript and has methods Here is the code for the cCONSOLE class CLASS cCONSOLE '= End of script - the cCONSOLE class code follows here '// Pause with the message "Hit enter to continue" print "Arg(" & ix & ")=" & wscript.arguments(ix)ĭim sMsg : sMsg =. '// List all the arguments on the console log '// Arguments are passed through correctly, if present '// Now we can use the Consol object to write to and read from the console '// Instantiate the console object, this automatically switches to CSCript if required To use it, include the complete class at the end of your script, and then instantiate it right at the beginning of the script. This assumes that your objective is to stream output to the console, rather than having output go to message boxes. I came across this post and went back to an approach that I used some time ago which is similar to main difference is that it uses a VBScript user-defined class to wrap all the logic for switching to CScript and outputting text to the console, so it makes the main script a bit cleaner. OWSH.Run vbsInterpreter & " //NoLogo " & Chr(34) & WScript.ScriptFullName & Chr(34)


If InStr(LCase(WScript.FullName), vbsInterpreter) = 0 Then The function ForceConsole() will execute your vbs into cscript, also you have nice alias to print and scan text. You only need to force cscript instead wscript.
