Here a review of your code Richard with my touch.
I forget wmi to run it on each platforms.
Code:
Break on
;Checking that KiXtart Forms DLL is Registered
$sid = ReadValue("HKEY_CLASSES_ROOT\Kixtart.Form\CLSID", "")
If NOT ReadValue("HKEY_CLASSES_ROOT\CLSID\$sid\InprocServer32", "ThreadingModel") = "Both"
MessageBox("KiXtart Forms Register DLL Failed, Please contact the IMT Helpdesk on x6049",
"Find User - KiXtart Forms DLL Register Failed", 0)
Exit 1
EndIf
;***********************************
;Create Object to KiXtart Form
$FORM = CreateObject("Kixtart.Form")
;***********************************
;Main Form
$FORM.Caption = "Find User (review)!!"
$FORM.ScaleHeight = 150
$FORM.ScaleWidth = 250
$FORM.FontSize = 8
$FORM.Center
;*******************************
;Current Directory Label
$lblUserName = $FORM.Label
$lblUserName.Text = "Type in your User Name you wish to search for: "
$lblUserName.Left = 5
$lblUserName.Top = 10
$lblUserName.Width = 380
$lblUserName.Height = 20
$lblUserName.FontSize = 8
$lblUserName.FONTNAME = "Arial"
$lblUserName.Enabled = 1
$UserNameButton = $FORM.CommandButton("Search User")
$UserNameButton.Left = 155
$UserNameButton.Top = 35
$UserNameButton.Width = 75
$UserNameButton.Height = 20
$UserNameButton.FontSize = 8
$UserNameButton.FONTNAME = "Arial"
$UserNameButton.OnClick = "MainFunction()"
$UserNameButton.default=1
$UserNameBox = $FORM.TextBox
$UserNameBox.Left = 15
$UserNameBox.Top = 35
$UserNameBox.Width = 120
$UserNameBox.Height = 20
$UserNameBox.FontSize = 8
$UserNameBox.FONTNAME = "Arial"
$ResultText = $FORM.Textbox
$ResultText.Left = 15
$ResultText.Top = 75
$ResultText.Width = 210
$ResultText.Height = 20
$ResultText.FontSize = 8
$ResultText.FONTNAME = "Arial"
$ResultText.enabled = 1
$ResultText.backcolor = 255,255,100
$quitbutton = $FORM.CommandButton("Exit")
$quitbutton.Left = 80
$quitbutton.Top = 125
$quitbutton.Width = 75
$quitbutton.Height = 20
$quitbutton.FontSize = 8
$quitbutton.FONTNAME = "Arial"
$quitbutton.OnClick = "Quit"
;*******************************
;Objects within Main Form
$FORM.Show ; Show Form
While $FORM.Visible
$=Execute($FORM.DoEvents)
Loop
Exit 1
;******************************
Function MainFunction()
$rdc="bas01"
$ResultText.ForeColor = 0.0.0
$user=$UserNameBox.text
If $user=""
$ResultText.Text = "The User Name field cannot be left blank !!"
$ResultText.ForeColor = 255.0.0
Exit
EndIf
If $user = @USERID
$ResultText.Text = "Are You Mad, '"+@USERID+"' is you!!"
$ResultText.ForeColor = 255.0.0
Exit
EndIf
$ResultText.Text ="Searching in local..."
$pc=ntname($user,"local")
If $pc =""
$ResultText.Text ="Searching on $rdc..."
$pc=ntname($user, $rdc)
EndIf
If $pc=""
$ResultText.Text = "User Name cannot be found."
$ResultText.ForeColor = 255.0.0
Else
$ResultText.Text = "$user found on $pc"
$ResultText.ForeColor = 0.0.0
EndIf
EndFunction
;***************************
Function ntname($user,$dc)
$tempfile="%temp%\ntname.txt"
If $dc ="local"
Shell '%comspec% /c ntname.exe $user > '+$tempfile
$=Open(3, $tempfile) = 0
$ntname = ReadLine(3)
$=Close (3)
Else
Shell '%comspec% /c rcmd \\$dc ntname.exe $user > '+$tempfile
$=Open(3, $tempfile) = 0
$x = ReadLine(3)
$x = ReadLine(3)
$ntname = ReadLine(3)
$=Close (3)
EndIf
Del $tempfile
EndFunction