#181870 - 2007-10-23 10:06 PM
Re: WSH issue w/ KF Kode
[Re: Glenn Barnas]
|
Benny69
Moderator
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
are you useing kix32.exe or wkix32.exe? well i should have to ask you that, my guess is that there is somthing in the code that is poping the command box, can you post your code?
|
Top
|
|
|
|
#181871 - 2007-10-23 10:53 PM
Re: WSH issue w/ KF Kode
[Re: Benny69]
|
Glenn Barnas
KiX Supporter
Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
|
WKix32 - I've associated .kxf with WKix32. Same deal with 4.53 & 4.6.
I doubt it's code, as it happens all the time.
Here's the WSHPipe udf (with headers removed), with a call to Ping Localhost. For me, a console window opens when I run "WKix32 .\test.kxf". I added the sleep commands to simulate the prep that goes on in my other commands. This example illustrates what happens before I instantiate KF, during initialization. Once KF has opened a form, future calls to WSH-related processes pop up additional windows - so it is not KF related.
Glenn
Break On
Sleep 3
$a = WSHPipe('ping localhost', 1)
Sleep 3
;Function:
; WshPipe()
;
;Author:
; Christopher Shilt (christopher.shilt@relizon.com)
Function WshPipe($ShellCMD, OPTIONAL $NoEcho)
Dim $oExec, $Output
$oExec = CreateObject("WScript.Shell").Exec($ShellCMD)
If Not VarType($oExec)=9 $WshPipe="WScript.Shell Exec Unsupported" Exit 10 EndIf
$Output = $oExec.StdOut.ReadAll + $oExec.StdErr.ReadAll
If Not $NoEcho $Output Endif
$WshPipe=Split(Join(Split($Output,CHR(13)),''),CHR(10))
Exit($oExec.ExitCode)
EndFunction
_________________________
Actually I am a Rocket Scientist!
|
Top
|
|
|
|
#181878 - 2007-10-24 01:58 AM
Re: WSH issue w/ KF Kode
[Re: Glenn Barnas]
|
Benny69
Moderator
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
I think you are right its not the code.
I have slightly modified the code to show the steps in the code:
Break On
Sleep 3
$a = WSHPipe('ping localhost', 1)
Sleep 3
;Function:
; WshPipe()
;
;Author:
; Christopher Shilt (christopher.shilt@relizon.com)
Function WshPipe($ShellCMD, OPTIONAL $NoEcho)
Dim $oExec, $Output
$oExec = CreateObject("WScript.Shell").Exec($ShellCMD)
? 1
Get $
If Not VarType($oExec) = 9
$WshPipe="WScript.Shell Exec Unsupported"
Exit 10
EndIf
$Output = $oExec.StdOut.ReadAll + $oExec.StdErr.ReadAll
? 2
Get $
If Not $NoEcho
$Output
EndIf
$WshPipe=Split(Join(Split($Output,Chr(13)),''),Chr(10))
Exit($oExec.ExitCode)
EndFunction
I think what is being seen is the output (maybe output is not the correct word) of ping.exe its self.
|
Top
|
|
|
|
#181890 - 2007-10-24 12:45 PM
Re: WSH issue w/ KF Kode
[Re: Jochen]
|
Jochen
KiX Supporter
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
here is a demo script posted by Shawn on kf.org:
Break On
$System = CreateObject("Kixtart.System")
$Form = $System.Form()
$Form.Size = 600,400
$Form.Text = "Kixpad"
$Form.FontName = "Tahoma"
$Form.FontSize = 8.25
$CommandLabel = $Form.Controls.Add("Label")
$CommandLabel.Left = 5
$CommandLabel.Top = 5
$CommandLabel.Width = 65
$CommandLabel.Text = "Command:"
$CommandLabel.TextAlign = "MiddleLeft"
$CommandTextBox = $Form.Controls.Add("TextBox")
$CommandTextBox.Top = $CommandLabel.Top
$CommandTextBox.Left = $CommandLabel.Right
$CommandTextBox.Right = $Form.ClientWidth - 90
$CommandTextBox.Anchor = 13
$CommandTextBox.Text = 'cmd /c dir %%systemroot%%'
$ExecuteButton = $Form.Controls.Add("Button")
$ExecuteButton.Text = "Execute"
$ExecuteButton.Top = $CommandLabel.Top
$ExecuteButton.Left = $CommandTextBox.Right + 10
$ExecuteButton.Anchor = 9
$ExecuteButton.OnClick = "ExecuteButton_Click()"
$ListingTextBox = $Form.Controls.Add("TextBox")
$ListingTextBox.MultiLine = "True"
$ListingTextBox.ScrollBars = "Both"
$ListingTextBox.Left = 5
$ListingTextBox.Top = $CommandLabel.Bottom + 5
$ListingTextBox.Right = $Form.ClientWidth - 5
$ListingTextBox.Bottom = $Form.ClientHEight - 35
$ListingTextBox.Anchor = 15
$ListingTextBox.FontName = "Courier New"
$ListingTextBox.FontSize = 10
$ListingTextBox.BackColor = "Black"
$ListingTextBox.ForeColor = "White"
$ListingTextBox.MaxLength = 0
$StyleLabel = $Form.Controls.Add("Label")
$StyleLabel.Left = 5
$StyleLabel.Top = $ListingTextBox.Bottom + 5
$StyleLabel.Width = 80
$StyleLabel.Text = "Window Style"
$StyleLabel.TextAlign = "MiddleLeft"
$StyleComboBox = $Form.Controls.Add("ComboBox")
$StyleComboBox.Top = $StyleLabel.Top
$StyleComboBox.Left = $StyleLabel.Right
$StyleComboBox.Width = 150
$StyleComboBox.DropDownStyle = 2
$WindowStyles = "Hidden", "Normal (focus)", "Minimized (focus)", "Maximized", "Normal", "Minimized"
For Each $Style In $WindowStyles
$= $StyleComboBox.AddItem($Style)
Next
$StyleComboBox.ListIndex = 4
$CloseButton = $Form.Controls.Add("Button")
$CloseButton.Top = $ListingTextBox.Bottom + 5
$CloseButton.Text = "Close"
$CloseButton.Left = $ExecuteButton.Left
$CloseButton.Anchor = 10
$CloseButton.OnClick = "CloseButton_Click()"
$Form.AcceptButton = $ExecuteButton
$Form.CancelButton = $CloseButton
$Form.Center
$Form.Show
$CommandTextBox.Focus
While $Form.Visible
$= Execute($Form.DoEvents)
Loop
Exit 0
Function CloseButton_Click()
$Form.Hide
EndFunction
Function ExecuteButton_Click()
$WindowStyle = $StyleComboBox.ListIndex
$ListingTextBox.Text = $System.Shell($CommandTextBox.Text,$WindowStyle,3)
EndFunction
You can set the WindowStyle to hidden, thus no console popup happens, and instead of assigning the console output to a TextBox text property you can
assign it to a variable for later analysis
Edited by Jochen (2007-10-24 01:13 PM)
_________________________
|
Top
|
|
|
|
#181893 - 2007-10-24 01:39 PM
Re: WSH issue w/ KF Kode
[Re: Jochen]
|
Benny69
Moderator
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
Code Tags, Code Tags! Man, slacker
|
Top
|
|
|
|
#181901 - 2007-10-24 02:56 PM
Re: WSH issue w/ KF Kode
[Re: Glenn Barnas]
|
Jochen
KiX Supporter
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
Well, I have to take the undocumented statement back ...
It is a Method of the System object, so I didn't find it immediately :
Kixforms Class Library Shell Method
Description Loads and runs a program.
Syntax object.Shell(command, window-style, redirection)
Parameters command
Command can be any 16-bit or 32-bit application. To run command interpreter commands, specify the correct command interpreter as part of the command.
window-style (optional)
One of the following values:
Value Setting Description 0 Hidden Window is hidden and focus is passed to the hidden window. 1 Normal (focused) Window has focus and is restored to its original size and position. 2 Minimized (focused) Window is displayed as an icon with focus. This is the default. 3 Maximized Window is maximized with focus. 4 Normal Window is restored to its most recent size and position. The currently active window remains active. 6 Minimized Window is displayed as an icon. The currently active window remains active.
redirection (optional)
One of the following values: Value Setting Description 0 None No redirection. This is the default. 1 Stdout Redirect standard output. 2 Stderr Redirect standard error. 3 Both Redirect both standard output and standard error.
Return Value If redirection is specified, returns the redirected output as a string; otherwise, returns the integer exit code of the command.
Remarks Script execution is stopped until the program exits.
Example $Listing = $System.Shell("cmd /c dir c:\myfolder", 0, 3)
For Each $Line In Split($Listing, @CRLF) ?"Line=" $Line Next See Also Applies To: System
It seems to have problems taking %ComSpec% as input though ...
Edited by Jochen (2007-10-24 03:00 PM)
_________________________
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
1 registered
(Allen)
and 382 anonymous users online.
|
|
|