Page 1 of 1 1
Topic Options
#182067 - 2007-10-29 11:19 PM kix2exe trouble
sjefferson Offline
Lurker

Registered: 2006-02-24
Posts: 4
I have a script that I am trying to turn into an exe file, which works fine until I try to use /runasuser /runaspassword. I get the following error message:

ERROR: unexpected command!
Script: C:\DOCUME~1\ [...]\ke2~1000842\k2erun.dat
Line: 112

Does anyone have any idea what may be going on here? I haven't used kix2exe before now, and don't know how to go about troubleshooting this issue.

Thanks,
Shawn

Top
#182069 - 2007-10-30 02:07 AM Re: kix2exe trouble [Re: sjefferson]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Can you show us the script or at least the section that is having the problem.
_________________________
Today is the tomorrow you worried about yesterday.

Top
#182101 - 2007-10-30 05:20 PM Re: kix2exe trouble [Re: Gargoyle]
sjefferson Offline
Lurker

Registered: 2006-02-24
Posts: 4
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

Top
#182104 - 2007-10-30 05:30 PM Re: kix2exe trouble [Re: sjefferson]
sjefferson Offline
Lurker

Registered: 2006-02-24
Posts: 4
Hmmm, looking at this a little more and I think it has something to do with the unregistering of the kixforms (?)

Edited by sjefferson (2007-10-30 07:49 PM)

Top
#182110 - 2007-10-30 07:58 PM Re: kix2exe trouble [Re: sjefferson]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
I did not look at the code in details but not having kixforms registered might be it.

Depending on for what kixforms you wrote the script each workstation you want to run this script on should have either the kixform.classic dll or the kixform.net dll registered.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#182122 - 2007-10-31 09:12 AM Re: kix2exe trouble [Re: Mart]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
I use something like the following to register KiXforms. If the object cannot be created the UDF attempts to use a local copy to register it.

Useful for deploying one-off tools to tech support staff - if they get an error they know that they just need to re-run the script with a privileged account.


$System=initKixForms()
If @ERROR
$=MessageBox("Sorry, you must install KiXForms to use this application. If you run the application as a power user it will automatically install KiXforms","Cannot start KiXForms",0,48)
Exit 0
EndIf


Function initKixForms(Optional $iMode) ; {{{
Dim $sDLL $sDLL="kixforms.dll"
Dim $sResource $sResource=@SCRIPTDIR
Dim $sTarget $sTarget=%SYSTEMROOT%+"\system32\"+$sDLL

$iMode=Val($iMode)

$initKixForms=CreateObject("Kixtart.System")
If @ERROR
Select
Case $iMode=1
Case "Default"
"Attempting KixForms install..."+@CRLF
COPY $sResource+"\"+$sDLL $sTarget
If @ERROR
"Can't copy file - requires elevated privilege"+@CRLF
Else
Shell 'regsvr32 /s "'+$sTarget+'"'
If @ERROR
"Can't register file - requires elevated privilege"+@CRLF
Else
$initKixForms=CreateObject("Kixtart.System")
EndIf
EndIf
EndSelect
EndIf

Exit @ERROR

EndFunction ; }}}
; vim600:ai sw=4 ts=4 fdc=4 fdm=marker



Edited by Richard H. (2007-10-31 09:15 AM)

Top
#182135 - 2007-10-31 05:55 PM Re: kix2exe trouble [Re: Richard H.]
sjefferson Offline
Lurker

Registered: 2006-02-24
Posts: 4
Hi,

That seems to have solved my problem! Although, I found that I have to have kixforms.dll registered on the machine BEFOREHAND, even though the user credentials I'm using to run the script (with /runasuser) should have admin rights to the local workstation. Anyway, thanks everyone for your help!

Shawn

Top
#182147 - 2007-10-31 07:07 PM Re: kix2exe trouble [Re: sjefferson]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
You can register the kixforms dll (classic and .net) with a start up script or deploy them with a GPO.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#182152 - 2007-10-31 10:08 PM Re: kix2exe trouble [Re: Mart]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
 Originally Posted By: Mart
You can register the kixforms dll (classic and .net) with a start up script or deploy them with a GPO.


It would need to be either a GPO or something like RunNas or the user would need Admin rights. You can quasi reg the classic with Power User rights but to properly do it you should have Admin rights.

If the user has rights or you're using RunNas you can actually add checking and installing code at the beginning of your code and not run the rest until it is installed and it should work as I recall (have not done anything like that type of testing though in many years)

Top
#182153 - 2007-11-01 12:16 AM Re: kix2exe trouble [Re: NTDOC]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
I have to disagree with you Doc.

Registering the classic dll with a start-up script works just fine. Ok it a BATch start-up script but that doesn't matter. Did this for many years until several months ago I implemented a KF.NET based logon script and you should use regasm instead of regsvr32. But I just took the easy way out and made a GPO that deploys the KF.NET MSI. Works just fine, no problems whatsoever. No need for power user or admin rights. Start-up scripts runs on the local system account so it should have local admin rights. If it is part of the logon script then some kind of elevated rights are needed indeed.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#182155 - 2007-11-01 02:10 AM Re: kix2exe trouble [Re: Mart]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Don't think we're in disagreement. I just left out the StartUp script which as you say is essentially the same, but in both cases it has Admin rights.

I was attempting to point out that installing it with only normal user or Power User would either fail or partially fail.

Top
#182162 - 2007-11-01 08:50 AM Re: kix2exe trouble [Re: NTDOC]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
And (computer) Startup Scripts are part of a GPO, so I presume that you both agree \:D
Top
#182163 - 2007-11-01 09:11 AM Re: kix2exe trouble [Re: NTDOC]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
Ahhh, ok. Sorry Doc. I misunderstood.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
2 registered (morganw, mole) and 414 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.068 seconds in which 0.023 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org