Page 22 of 39
Posted: Fri Dec 19, 2008 1:05 am
by Kiffi
@SFSxOI: try to insert a COMate_GetLastErrorDescription() after the invoke statement.
Code: Select all
[...]
WshShell\Invoke("Run 'netsh int tcp set global ecncapability=enabled'")
Debug COMate_GetLastErrorDescription()
[...]
does it returns an 'OK' or an 'Error'?
Greetings ... Kiffi
Posted: Fri Dec 19, 2008 1:06 am
by SFSxOI
Yep, your right srod, was just gonna post back with the same thing, works perfectly now
Code: Select all
Define WshShell.COMateObject
WshShell = COMate_CreateObject("WScript.Shell")
If WshShell
WshShell\Invoke("Run('netsh int tcp set Global ecncapability=enabled')")
WshShell\Release()
Else
Debug "!WshShell"
EndIf
Thanks srod and Kiffi
Now i can start converting all of my old .vbs scripts for netsh

Posted: Fri Dec 19, 2008 1:17 am
by srod
Yes COMate's command parser requires the brackets after the method name. I could easily alter this if required?
Posted: Fri Dec 19, 2008 11:39 am
by SFSxOI
Its no big deal srod, I just got to remember to put the brackets

but thanks for the offer.
I think that even though i have problems remembering the brackets, the thing i have problems with the most are the escape codes in relation to strings, I seem to always forget the ' or something and spend much time before I realize how dumb i was to overlook something like that.
Heres some script conversions for Netsh in Vista and Server 2008 that are used to tune the TCP stack in each. Changes take effect immediately and no reboot needed.
Code: Select all
XIncludeFile "COMate.pbi"
XIncludeFile "VariantHelper_Include.pb"
; NETSH scripts for Windows Vista and Server 2008
; Changes take effect immediately - no reboot needed
; PureBasic 4.30 and COMate by srod
; By SFSxOI - December 2008
; ECN Capability - Ecn_EnableDisable(ecn_enbdis.s)
; where - ecn_enbdis.s is one of the following
; enable : some routers have issues with this enabled, not suggested and need to test first
; disable : this is the default state and recommended setting
; default : restores the system default
Procedure Ecn_EnableDisable(ecn_enbdis.s)
Define WshShell.COMateObject
WshShell = COMate_CreateObject("WScript.Shell")
If WshShell
If ecn_enbdis = "enable"
WshShell\Invoke("Run('netsh int tcp set Global ecncapability=enable')")
EndIf
If ecn_enbdis = "disable"
WshShell\Invoke("Run('netsh int tcp set Global ecncapability=disable')")
EndIf
If ecn_enbdis = "default"
WshShell\Invoke("Run('netsh int tcp set Global ecncapability=default')")
EndIf
WshShell\Release()
EndIf
EndProcedure
; TCP Auto-Tuning - TCP_Auto_Tune(auto_tune.s)
; where - auto_tune.s is one of the following
;normal : Default value, allows the receive window To grow To accommodate most conditions
;highlyrestricted : allows the receive window To grow beyond default value very conservatively
;restricted : somewhat restricted growth of the tcp receive window beyond its Default value
;disabled : uses a fixed value For the tcp receive window. Limits it To 64KB (limited at 65535).
;experimental : allows the receive window to grow to accommodate extreme scenarios
;NOTE: experimental setting not recommended, it can degrade performance in common scenarios, only intended For research purposes. It enables RWIN values of over 16 MB
; If you experience problems with your NAT router or SPI firewall, try the "restricted", "highlyrestricted", or even "disabled" state.
; recomended normal unless you are having problems
Procedure TCP_Auto_Tune(auto_tune.s)
Define WshShell.COMateObject
WshShell = COMate_CreateObject("WScript.Shell")
If WshShell
If auto_tune = "normal"
WshShell\Invoke("Run('netsh int tcp set global autotuninglevel=normal')")
EndIf
If auto_tune = "highlyrestricted"
WshShell\Invoke("Run('netsh int tcp set global autotuninglevel=highlyrestricted')")
EndIf
If auto_tune = "restricted"
WshShell\Invoke("Run('netsh int tcp set global autotuninglevel=restricted')")
EndIf
If auto_tune = "disabled"
WshShell\Invoke("Run('netsh int tcp set global autotuninglevel=disabled')")
EndIf
If auto_tune = "experimental"
WshShell\Invoke("Run('netsh int tcp set global autotuninglevel=experimental')")
EndIf
WshShell\Release()
EndIf
EndProcedure
; Compound TCP - Con_TCP(level_ctcp.s)
; where - level_ctcp.s is one of the following
; ctcp : recommended setting (default for Server 2008)
; none : no congestion control at all (default for Windows Vista)
; Default : restores the system default
; Recommended setting: ctcp
; It is better To use this newer generation CTCP congestion control algorithm For most broadband connections,
; NOTE: By default Vista has CTCP turned off (none), and Server 2008 has CTCP turned on (ctcp).
; NOTE : Turning this option on can significantly increase throughput (not bandwidth).
Procedure Con_TCP(level_ctcp.s)
Define WshShell.COMateObject
WshShell = COMate_CreateObject("WScript.Shell")
If WshShell
If level_ctcp = "ctcp"
WshShell\Invoke("Run('netsh int tcp set Global congestionprovider=ctcp')")
EndIf
If level_ctcp = "none"
WshShell\Invoke("Run('netsh int tcp set Global congestionprovider=none')")
EndIf
If level_ctcp = "default"
WshShell\Invoke("Run('netsh int tcp set Global congestionprovider=default')")
EndIf
WshShell\Release()
EndIf
EndProcedure
; RSS - Receive-side Scaling - Rss_Scale(scale_rss.s)
; where - scale_rss.s is one of the following
; enabled : Default - enables receive side scaling
; disabled : disables receive side scaling
; default : returns to system default
; Recommended: enabled (If you have 2 Or more processor cores And a NIC that can handle RSS)
Procedure Rss_Scale(scale_rss.s)
Define WshShell.COMateObject
WshShell = COMate_CreateObject("WScript.Shell")
If WshShell
If scale_rss = "enabled"
WshShell\Invoke("Run('netsh int tcp set global rss=enabled')")
EndIf
If scale_rss = "disabled"
WshShell\Invoke("Run('netsh int tcp set global rss=disabled')")
EndIf
If scale_rss = "default"
WshShell\Invoke("Run('netsh int tcp set global rss=default')")
EndIf
WshShell\Release()
EndIf
EndProcedure
; TCP Chimney Offload - TCP_Chimney_Offload(tcp_offload.s)
; where - tcp_offload.s is one of the following
; enabled : enables TCP Chimney Offload (Default)
; disabled : disables TCP Chimney Offload
; default : returns to default system default
; Recommended: enabled
Procedure TCP_Chimney_Offload(tcp_offload.s)
Define WshShell.COMateObject
WshShell = COMate_CreateObject("WScript.Shell")
If WshShell
If tcp_offload = "enabled"
WshShell\Invoke("Run('netsh int tcp set global chimney=enabled')")
EndIf
If tcp_offload = "disabled"
WshShell\Invoke("Run('netsh int tcp set global chimney=disabled')")
EndIf
If tcp_offload = "default"
WshShell\Invoke("Run('netsh int tcp set global chimney=default')")
EndIf
WshShell\Release()
EndIf
EndProcedure
; Time Stamp 1323 - TimeStamp_1323(time_stamp.s)
; where - time_stamp.s is one of the following
; enabled : Time Stamp 1323 enabled (recommended for most)
; disabled : Time Stamp 1323 disabled (default)
Procedure TimeStamp_1323(time_stamp.s)
Define WshShell.COMateObject
WshShell = COMate_CreateObject("WScript.Shell")
If WshShell
If time_stamp = "enabled"
WshShell\Invoke("Run('netsh int tcp set global timestamps=enabled')")
EndIf
If time_stamp = "disabled"
WshShell\Invoke("Run('netsh int tcp set global timestamps=disabled')")
EndIf
WshShell\Release()
EndIf
EndProcedure
Posted: Sat Dec 20, 2008 11:46 am
by SFSxOI
how do you get a dotted IP address into a command when the dotted IP address can't be a string?
Like this:
Code: Select all
netsh interface ip set address "Local Area Connection" static 192.168.0.10 255.255.255.0 192.168.0.1 1
Posted: Sat Dec 20, 2008 12:08 pm
by srod
Why not a string? Looking at the help for netsh; it certainly seems to require a string.
Posted: Sat Dec 20, 2008 1:01 pm
by SFSxOI
Thats what I thought at first also, that it was a string in COMate. But if you use the netsh in an admin command prompt you specifically designate strings with the netsh command with the quote marks " ", and the only part that is specifically designated a string in the command is the "Local Area Connection" part. In the command prompt the IP addreses aren't strings.
I tried using them as strings in the COMate command, and although it ran without error it didn't do what it was supposed to do.
Maybe i'm doing it wrong or something with COMate...back to the drawing board I guess.
The help says this:
Code: Select all
Usage: set address [name=]<string>
[[source=]dhcp|static]
[[address=]<IPv4 address>[/<integer>] [[mask=]<IPv4 mask>]
[[gateway=]<IPv4 address>|none [gwmetric=]<integer>]
[[type=]unicast|anycast]
[[subinterface=]<string>]
[[store=]active|persistent]
where only the name (connection name) is a string, and the addresses are integers. So if it expects an integer for the IP addresses how do you get the integer into the COMate command line? AS type-modifier of some sort? AS INTEGER (if there is one) ?
Posted: Sat Dec 20, 2008 8:20 pm
by srod
Well if you wish to pass an integer variable just use Str() etc. There is no need to use " as integer" although you can do if you wish.
E.g. (passing an integer variable as a BOOLEAN) :
Code: Select all
regExObject\SetProperty("IgnoreCase = " + Str(bIgnoreCase) + " AS BOOLEAN")
Posted: Sat Dec 20, 2008 10:01 pm
by SFSxOI
doesn't matter what i do, its not working. Oh well.....I know its sending the command to netsh, its just not doing what its supposed to as as if it were typed directly into the command prompt.
Anyway, heres the lasted thing i've tried, and i've tried all sorts of variations and mixes, etc...and i'm back to trying to do it with strings again. Am I using the escape sequences correctly ?
Code: Select all
Procedure Stac_IP(connection_name.s, desired_IP.s, sub_net_mask.s, gw_router.s)
Define WshShell.COMateObject
WshShell = COMate_CreateObject("WScript.Shell")
If WshShell
WshShell\Invoke("Run('netsh interface ip set address $0027" + connection_name + "$0027 static $0027" + desired_IP + "$0027 $0027" + sub_net_mask + "$0027 $0027" + gw_router + "$0027')")
WshShell\Release()
EndIf
EndProcedure
and i'm also trying it the older way which still works instead of the abbreviated version by using this line:
Code: Select all
WshShell\Invoke("Run('netsh interface ip set address name= $0027" + connection_name + "$0027 source= $0027" + static_change$ + "$0027 addr= $0027" + desired_IP + "$0027 mask= $0027" + sub_net_mask + "$0027 gateway= $0027" + gw_router + "$0027')")
Posted: Fri Dec 26, 2008 5:22 pm
by KIKI
I have the folowing error message return by comate
Unknown error. (Code : Hex FFFFFFFF80020003). Please report this error code to the author at '
enquiries@nxsoftware.com'
Here is the context
Code: Select all
RegisterActiveX(GetCurrentDirectory()+"AutoItX3.dll")
automation = COMate_CreateObject("AutoItX3.Control")
anf this is these intstruction wich cause a crash
Automation\SetPropertyRef("ControlSetText('Importation complète...','Regarder &dans','Edit1',"+"'" +strChemin +"')")
Description of ControlSetText
ControlSetText "title", "text", "controlID", "new text"
Parameters
title The title of the window to access.
text The text of the window to access.
controlID The control to interact with. See Controls.
new text The new text to be set into the control.
Return Value
Success: Returns 1.
Failure: Returns 0 if window/control is not found.
Posted: Fri Dec 26, 2008 6:54 pm
by srod
That is a 'Member not found' error. Try using Invoke instead of SetPropertyRef and also double check the classname of the control; is it really "Edit1" ? You can also try setting the first two parameters to null strings etc.
Posted: Mon Dec 29, 2008 10:34 pm
by srod
Bug fix - 29th Dec. 2008.
COMate version 1.1.9.
First, only the version of COMate for PB 4.3 has had this bug fix. COMate for PB 4.2 remains at version 1.1.7
A quite major shortcoming on COMate's part meant that it would effectively ignore some ActiveX control's events (e.g. ShockwaveFlash). I blame this on a severe lack of documentation on MS's part!
This has been fixed.
See the nxSoftware site for the download.
Posted: Sat Jan 10, 2009 8:23 am
by KIKI
Hi srod,
Hapy new year.
Here is my problem from my program HTML mailer (CDO and comate programm) see my post.
Someone wonder me how to see if the mail was send correctly.
But the send function doesn(t retrun anaything except thazn in visual basic error vraibla have a code returning error.
How can i do to intercept that's message to see if yhe mail was send correctly ? Have you an idea.
Thanks in advance
Posted: Sat Jan 10, 2009 11:32 am
by srod
Hi,
happy new year to you KIKI.
Unfortunately I know very very little about CDO, so am unable to shed any light on this I'm afraid.
Posted: Tue Jan 13, 2009 7:35 pm
by X
srod wrote:
Right, I'm off to study 'Event sinks' now... Let's hope I have more luck than I generally do with kitchen sinks!

Hello! Just checking back in to see if this has come around yet

VBScripts allows scripts to call application functions directly, and the other way around (allow applications to call script functions directly), and yet, allows events to bubble up from events.
I was wondering how this project was coming along.