Page 1 of 1

Executing VBScript for disabling network adapters

PostPosted: Fri Aug 21, 2015 10:32 am
by stu
I'm currently trying to deactivate network devices on demand from a Neobook application by using the following VBScript:

Syntax: [ Download ] [ Hide ]
Using Visual Basic Syntax Highlighting
'===================================================
' VBScript:  AUTHOR: Ed Wilson , MS,  5/5/2004
' NAME: <turnONoffNet.vbs>
' COMMENT: Key concepts are listed below:
'1.uses the c:\devcon utility to turn on or off net
'2.uses a vbyesNO msgBOX to solicit input
'3. KB 311272  talks about devcon and shows where to get
'====================================================

Option Explicit
Dim objShell
Dim objExec
Dim onWireLess
Dim onLoopBack
Dim turnON
Dim turnOFF
Dim yesNO
Dim message, msgTitle
Dim strText

message = "Turn On Wireless? Loop is disabled" & vbcrlf & "if not, then wireless is disabled and loop enabled"
msgTitle = "change Network settings"
onWireLess = " PCMCIA\Dell-0156-0002"
onLoopBack = " *loop"
turnON = "enable"
turnOFF = "disable"
Const yes = 6

Set objShell = CreateObject("wscript.shell")
yesNO = MsgBox(message,vbyesNO,msgTitle)

If yesNO = yes Then
     WScript.Echo "yes chosen"
     Set objExec = objShell.exec("cmd /c c:\devcon " & turnON & onWireLess)
     subOUT
     Set objExec = objShell.exec("cmd /c c:\devcon " & turnOFF & onLoopBack)
     subOUT
Else
     WScript.Echo "no chosen"
     Set objExec = objShell.exec("cmd /c c:\devcon " & turnOFF & onWireLess)
     subOUT
     Set objExec = objShell.exec("cmd /c c:\devcon " & turnON & onLoopBack)
     subOUT
End If

Sub subOUT
Do until objExec.StdOut.AtEndOfStream
strText = objExec.StdOut.ReadLine()
Wscript.Echo strText
Loop

End sub
Parsed in 0.007 seconds, using GeSHi 1.0.8.10


Unfortunately I havent been able to overcome the following error on execution:

Image

Additionally. Does anyone care to explain how to execute a console comand from neobook... Maybe something like NET USER /DOMAN. Or even, if possible, execute a netcat instance with some parameters.

Regards!

Re: Executing VBScript for disabling network adapters

PostPosted: Fri Aug 21, 2015 12:07 pm
by Neosoft Support
I think you just need to remove the calls to Wscript.Echo. That command is intended to output a message on the console. Since NeoBook is a graphic mode app and not a console app you can't "echo" something to the screen. You can remove the Wscript.Echo commands entirely or replace them with MsgBox ("text").

Re: Executing VBScript for disabling network adapters

PostPosted: Fri Aug 21, 2015 12:15 pm
by stu
Neosoft Support wrote:I think you just need to remove the calls to Wscript.Echo. That command is intended to output a message on the console. Since NeoBook is a graphic mode app and not a console app you can't "echo" something to the screen. You can remove the Wscript.Echo commands entirely or replace them with MsgBox ("text").


Thanks!

What about using RUN command in NB for opening a console and executing a command:

sort of

CMD
NET USER /DOMAIN

Regards

Re: Executing VBScript for disabling network adapters

PostPosted: Fri Aug 21, 2015 5:22 pm
by Neosoft Support
You can experiment with the Run action. It might work as well.

Re: Executing VBScript for disabling network adapters

PostPosted: Fri Aug 21, 2015 5:34 pm
by stu
Neosoft Support wrote:You can experiment with the Run action. It might work as well.


I was into a way of executing accions for a cli application that kills tasks, some applications go to the system tray when you close them from CMD with traditional methods, uTorrent is an example. So PsKill.exe (http://ss64.com/nt/pskill.html) is the best option... i decided to include it into the end product and use a BAT file to call it:

Code: Select all
pskill.exe /accepteula uTorrent.exe
exit


I just use RUN from Neobook end of the day works as expected...

=)

Re: Executing VBScript for disabling network adapters

PostPosted: Sat Aug 22, 2015 10:24 pm
by mishem
There are plug-in to capture and redirect the output to the console application project.

dmCMDLine

Download.

Re: Executing VBScript for disabling network adapters

PostPosted: Fri Aug 28, 2015 4:29 am
by stu
mishem wrote:There are plug-in to capture and redirect the output to the console application project.

dmCMDLine

Download.


I dunno why but by using:

dmRun "C:\Windows\System32\cmd.exe" "netstat -a" "[NetstatResult]" "False" "False"

I get only the Windows version info, check it out:

Image

Re: Executing VBScript for disabling network adapters

PostPosted: Fri Aug 28, 2015 8:13 am
by Tony Kroos
Check the sample pub for netstat.exe and cmd.exe usage.

setvar "[CMDApp]" "[SystemDir]netstat.exe"
setvar "[CMDLine]" "-a"
dmRun "[CMDApp]" "[CMDLine]" "[NetstatResult]" "False" "False"

setvar "[CMDApp]" "[SystemDir]cmd.exe"
setvar "[CMDLine]" "/c netstat -a"
dmRun "[CMDApp]" "[CMDLine]" "[NetstatResult]" "False" "False"

Also, did you create OnConsoleBuffer subroutine in your pub? It is triggered when the console displays new piece of data for reading.
In case it exists, [NetstatResult] will contain only currently reading block of console data at the current moment (when subroutine is triggered), you must implement your own actions to concatenate results. So you probably getting only last portion of output.
In case it doesn't exist, all console output will be placed in [NetstatResult] AFTER netstat.exe is finished so you won't get any output during execution. You have to wait, it may take minutes to get all connections stats.
Also note if you execute dmRun in parallel thread (first parameter is False, to avoid GUI freeze) OnConsoleBuffer is not used, so you just have to wait until netstat is finished to get the output.

Re: Executing VBScript for disabling network adapters

PostPosted: Fri Aug 28, 2015 9:59 am
by stu
Tony Kroos wrote:Check the sample pub for netstat.exe and cmd.exe usage.

setvar "[CMDApp]" "[SystemDir]netstat.exe"
setvar "[CMDLine]" "-a"
dmRun "[CMDApp]" "[CMDLine]" "[NetstatResult]" "False" "False"

setvar "[CMDApp]" "[SystemDir]cmd.exe"
setvar "[CMDLine]" "/c netstat -a"
dmRun "[CMDApp]" "[CMDLine]" "[NetstatResult]" "False" "False"

Also, did you create OnConsoleBuffer subroutine in your pub? It is triggered when the console displays new piece of data for reading.
In case it exists, [NetstatResult] will contain only currently reading block of console data at the current moment (when subroutine is triggered), you must implement your own actions to concatenate results. So you probably getting only last portion of output.
In case it doesn't exist, all console output will be placed in [NetstatResult] AFTER netstat.exe is finished so you won't get any output during execution. You have to wait, it may take minutes to get all connections stats.
Also note if you execute dmRun in parallel thread (first parameter is False, to avoid GUI freeze) OnConsoleBuffer is not used, so you just have to wait until netstat is finished to get the output.


sweet! works like a charm! Yet another plugin I did'nt have a clue about...

Thanks for your help

Re: Executing VBScript for disabling network adapters

PostPosted: Mon Aug 31, 2015 10:37 am
by dpayer
[quote="Tony Kroos"]Also, did you create OnConsoleBuffer subroutine in your pub? It is triggered when the console displays new piece of data for reading.
[/quote="Tony Kroos"]

The plugin looks very interesting but an even rudimentary translation would be helpful. I can't see from the dialogue box what the parameters are meant to be.

The .ru site is helpful when translated but not quite enough for me to grasp. Kudos to the developer.

Re: Executing VBScript for disabling network adapters

PostPosted: Mon Aug 31, 2015 12:47 pm
by stu
dpayer wrote:
Tony Kroos wrote:Also, did you create OnConsoleBuffer subroutine in your pub? It is triggered when the console displays new piece of data for reading.
[/quote="Tony Kroos"]

The plugin looks very interesting but an even rudimentary translation would be helpful. I can't see from the dialogue box what the parameters are meant to be.

The .ru site is helpful when translated but not quite enough for me to grasp. Kudos to the developer.


x2

It would be extremely nice if the Russian forum could include an English area. (?) Maybe just so people could ask about the plugins they have.

Re: Executing VBScript for disabling network adapters

PostPosted: Mon Aug 31, 2015 6:24 pm
by mishem
It would be extremely nice if the Russian forum could include an English area. (?) Maybe just so people could ask about the plugins they have.


Don't hesitate to ask at the Russian forum questions in any language.

Re: Executing VBScript for disabling network adapters

PostPosted: Mon Aug 31, 2015 11:36 pm
by Tony Kroos
Or you may ask here in Russian section (in case you cannot bypass registration)

Re: Executing VBScript for disabling network adapters

PostPosted: Tue Sep 01, 2015 5:01 am
by stu
Cheers dudes, I had some trouble with the avatar thing... its all good now... DEMBEL plugins are pure gold, I have to say.