Executing VBScript for disabling network adapters
Moderator: Neosoft Support
Executing VBScript for disabling network adapters
I'm currently trying to deactivate network devices on demand from a Neobook application by using the following VBScript:
[syntax=vb]'===================================================
' 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[/syntax]
Unfortunately I havent been able to overcome the following error on execution:
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!
[syntax=vb]'===================================================
' 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[/syntax]
Unfortunately I havent been able to overcome the following error on execution:
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!
-
- NeoSoft Team
- Posts: 5628
- Joined: Thu Mar 31, 2005 10:48 pm
- Location: Oregon, USA
- Contact:
Re: Executing VBScript for disabling network adapters
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").
NeoSoft Support
Re: Executing VBScript for disabling network adapters
Thanks!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").
What about using RUN command in NB for opening a console and executing a command:
sort of
CMD
NET USER /DOMAIN
Regards
-
- NeoSoft Team
- Posts: 5628
- Joined: Thu Mar 31, 2005 10:48 pm
- Location: Oregon, USA
- Contact:
Re: Executing VBScript for disabling network adapters
You can experiment with the Run action. It might work as well.
NeoSoft Support
Re: Executing VBScript for disabling network adapters
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:Neosoft Support wrote:You can experiment with the Run action. It might work as well.
Code: Select all
pskill.exe /accepteula uTorrent.exe
exit
=)
-
- Posts: 419
- Joined: Thu Oct 15, 2009 3:43 pm
Re: Executing VBScript for disabling network adapters
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.
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
sweet! works like a charm! Yet another plugin I did'nt have a clue about...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.
Thanks for your help
Re: Executing VBScript for disabling network adapters
[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.
[/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.
David Payer
Des Moines, Iowa
USA
Des Moines, Iowa
USA
Re: Executing VBScript for disabling network adapters
x2dpayer 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.
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
Don't hesitate to ask at the Russian forum questions in any language.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.
-
- Posts: 419
- Joined: Thu Oct 15, 2009 3:43 pm
Re: Executing VBScript for disabling network adapters
Or you may ask here in Russian section (in case you cannot bypass registration)
Re: Executing VBScript for disabling network adapters
Cheers dudes, I had some trouble with the avatar thing... its all good now... DEMBEL plugins are pure gold, I have to say.