That's the trouble I'm having, since I can't actually see what's at line 112 in the script. My original script doesn't even have 100 lines.

Here's the script anyway:


Break On

Dim $Sessions[60,2]
Dim $line
Dim $x
Dim $RadioButtons[60]
Dim $session

; Run qwinsta to enumerate sessions
SHELL "%comspec% /c qwinsta.exe /server:nmmtermserv01 > userlist.txt"

; Parse the session list
$x = 0
IF OPEN (10, "userlist.txt") = 0
$line = READLINE(10)
$line = READLINE(10)
$line = READLINE(10)
$line = READLINE(10)
WHILE @ERROR = 0
$Sessions[$x,0] = RTrim(SubStr($line,20,20))
$Sessions[$x,1] = LTrim(SubStr($line,42,5))
;? "Username:" + $Sessions[x,0] + " Session ID: " + $Sessions[x,1]
$line = ReadLine(10)
$x = $x + 1
LOOP
ENDIF
$nul = CLOSE(10)
DEL "userlist.txt"

$session = 10000

; Display form with KixForms
$Form = CreateObject("Kixtart.Form")
$Form.FontName = "Tahoma"
$Form.FontSize = 10
$Form.FormBorderStyle = 4
$Form.SizeGripStyle = 1
$Form.Size = 600,500
$Form.Text = "Reset GP Terminal Session"
$Form.tag = 0

$GroupBox = $Form.Controls.Add("GroupBox")
$GroupBox.Top = 10
$GroupBox.Left = 10
$GroupBox.Height = $Form.Height - 110
$GroupBox.Width = $Form.Width - 20

$y = 10
For $x = 0 To 59
If $Sessions[$x,0] <> ""
$RadioButtons[$x] = $GroupBox.Controls.Add("RadioButton")
$RadioButtons[$x].Top = $y + (($x mod 15) * $RadioButtons[x].Height)
$RadioButtons[$x].Left = 10 + (120 * ($x / 15))
$RadioButtons[$x].Name = $Sessions[$x,0]
$RadioButtons[$x].Text = $Sessions[$x,0]
$RadioButtons[$x].Width = 120
$RadioButtons[$x].OnClick = "$$session = $Sessions[$x,1]"
EndIf
Next

$Button = $Form.ToolButton
$Button.Top = $Form.ClientHeight - $Button.Height - 10
$Button.Left = $Form.ClientWidth - $Button.Width - 10
$Button.Text = "Reset"
$Button.Icon = 37
$Button.OnClick = "$$form.tag=1"
$Button.Anchor = 2+8


$Form.Center
$Form.Show
While $Form.Visible and $form.tag = "0"
$= Execute($Form.DoEvents)
Loop

if $form.tag = "1"
RUN "%comspec% /c RESET SESSION $session /server:nmmtermserv01"
else

endif

Exit 0