Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Returning a value from an exe

Status
Not open for further replies.

azrael811

MIS
Sep 2, 2003
13
0
0
AU
I wish to use the rascheck.exe utility in a login script to determine if users are connecting via ras. If I run the checkras from the commandline of a ras client it returns "CHECKRAS: 1 connections" to the screen. If I run checkras as part of the following script RAS returns the value of 0 which is the error code.

'------------------------------------------------

Set ws = CreateObject("WScript.Shell")

LogonServer = ws.ExpandEnvironmentStrings("%LOGONSERVER%")

CheckRasExe = (LogonServer & "\netlogon\checkras.bat")


RAS = ws.Run(CheckRasExe)

wscript.echo RAS

'------------------------------------------------

I wish to return the value that checkras outputs to the commandline to a variable in my script. How can I achieve this ?
 
Try something like this:
Code:
Set ws = CreateObject("WScript.Shell")
LogonServer = ws.ExpandEnvironmentStrings("%LOGONSERVER%")
CheckRasExe = (LogonServer & "\netlogon\checkras.bat")
Set X = ws.Exec(CheckRasExe)
Do While X.Status = 0
  WScript.Sleep 100
Loop
RAS = X.StdOut.ReadAll
wscript.echo RAS
You can also use the StdErr property


Hope This Help
PH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top