Originally Posted By: Richard H.
Give it a go and report back - both if it dows not work for you and also if it does. That way other people who stumble across this thread will be able to make use of the information.


Good point.
Yes, I've tried it and it will work. Now the problem seems that I can't get this script to pass either error (0 or 1) to a VB script. Here's what I'm trying to do.

In an Access database a button is pressed and it first detects that a PC listed in a field is available via a %comspec% call to ping.
If the PC does ping, I need it to check if the current user is a local admin.
If yes, then it will proceed with the next function (various WMI queries).
If no, it needs to return the proper error.

Here's the VB code:
 Code:
Function IsAdmin()
Dim oShell
Dim oFSO
Dim sTemp
Dim sTempFile
Dim fFile
Dim sResults

    Const OpenAsDefault = -2
    Const FailIfNotExist = 0
    Const ForReading = 1
    
    Set oShell = CreateObject("WScript.Shell")
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    sTemp = oShell.ExpandEnvironmentStrings("%TEMP%")
    sTempFile = sTemp & "\inv_isadmin.tmp"

    oShell.Run "%comspec% /c kix32 %systemroot%\userislocaladmin.kix"
End Function
Private Sub CompAvail()
If IsConnectible(strComputer, 1, 750) Then 'Pings strComputer
   If IsAdmin = 1 Then
      WMIwrapper
   Else: MsgBox "    The operation has received an error. It is highly likely that" & Chr(13) & _
           "    you received this error due to a lack of administrator privileges " & Chr(13) & _
           "    on the remote computer. Please check the computer before " & Chr(13) & _
           "    reattempting this connection.", vbExclamation, "Error - Check permissions"
   End If
Else:
  Err_Handler
End If

End Sub

The KiX code is simply "LocalAdmin" which I have seen return a "1".
(I had to reformat the above code after I pasted. It looks right but I may have missed something.)
The result of all of this is the KiX script, when ran, flashes a 1, and then the VB script proceeds with Else statement and doesn't run the WMIwrapper function.
Now, I realize this is a forum for KiX but I'm hoping that someone will still be able to tell me where I'm going wrong, whether it's in the VB or KiX.

If it's VB, just tell me it's wrong and that's enough. I'll start looking for the answers elsewhere. I feel stupid for posting this on this forum but this is the only forum that I've had any help with recently .