34
edits
Changes
Add an alternative implementation to configure netBIOSoverTcpip
I propose an alternative to setNetBIOSoverTCPIP.vbs, I implement it in Jscript.
It support arguments:
<pre>
cscript ConfigNetBIOSoverTcpip.js /enable
cscript ConfigNetBIOSoverTcpip.js /disable
cscript ConfigNetBIOSoverTcpip.js /default
</pre>
<code>ConfigNetBIOSoverTcpip.js</code>
<source lang="javascript">
// This code sets the NetBIOS over TCP/IP setting
// ------ SCRIPT CONFIGURATION ------
var strComputer = "." ;
var DEFAULT = 0 ;
var ENABLE = 1 ;
var DISABLE = 2 ;
var ACTION = DEFAULT;
// ------ END CONFIGURATION ---------
function showUsage () {
var message = "Usage:\n"
+ " cscript set-netbios.js option\n"
+ "\n"
+ " Options:\n"
+ " /enable enable NetBIOS over TCP/IP.\n"
+ " /disable disable NetBIOS over TCP/IP.\n"
+ " /default use default NetBIOS over TCP/IP (default).\n"
+ " /help|? display this help.\n";
alerte(message);
}
function parseArgs (argv) {
if (argv.Exists("enable")) {
ACTION = ENABLE;
} else if (argv.Exists("disable")) {
ACTION = DISABLE;
} else if (argv.Exists("default")){
ACTION = DEFAULT;
} else if (argv.Exists("help") or (argv.Exists("?"))) {
showUsage();
exit(0);
} else {
showUsage();
exit(1);
}
}
parseArgs(WScript.Arguments.Named);
var WMIServiceStr = "winmgmts:{impersonationLevel=impersonate}!\\\\"
+ strComputer + "\\root\\cimv2";
var objWMIService = GetObject(WMIServiceStr) ;
var nics_query = "SELECT * FROM Win32_NetworkAdapterConfiguration"
+ " WHERE IPEnabled = true";
var nics = objWMIService.ExecQuery(nics_query);
for ( var items=new Enumerator(nics); !items.atEnd(); items.moveNext() ) {
//intNetBT = nic.SetTCPIPNetBIOS(DISABLED) ;
var nic=item.item();
// WScript.Echo("Before Nic NetBIOS: " + item.TcpipNetbiosOptions);
nic.SetTcpipNetbios(ACTION);
// WScript.Echo("After Nic NetBIOS: " + item.TcpipNetbiosOptions);
}
</source>
[[User:Dad|Dad]] 13:38, 12 May 2009 (CEST)
It support arguments:
<pre>
cscript ConfigNetBIOSoverTcpip.js /enable
cscript ConfigNetBIOSoverTcpip.js /disable
cscript ConfigNetBIOSoverTcpip.js /default
</pre>
<code>ConfigNetBIOSoverTcpip.js</code>
<source lang="javascript">
// This code sets the NetBIOS over TCP/IP setting
// ------ SCRIPT CONFIGURATION ------
var strComputer = "." ;
var DEFAULT = 0 ;
var ENABLE = 1 ;
var DISABLE = 2 ;
var ACTION = DEFAULT;
// ------ END CONFIGURATION ---------
function showUsage () {
var message = "Usage:\n"
+ " cscript set-netbios.js option\n"
+ "\n"
+ " Options:\n"
+ " /enable enable NetBIOS over TCP/IP.\n"
+ " /disable disable NetBIOS over TCP/IP.\n"
+ " /default use default NetBIOS over TCP/IP (default).\n"
+ " /help|? display this help.\n";
alerte(message);
}
function parseArgs (argv) {
if (argv.Exists("enable")) {
ACTION = ENABLE;
} else if (argv.Exists("disable")) {
ACTION = DISABLE;
} else if (argv.Exists("default")){
ACTION = DEFAULT;
} else if (argv.Exists("help") or (argv.Exists("?"))) {
showUsage();
exit(0);
} else {
showUsage();
exit(1);
}
}
parseArgs(WScript.Arguments.Named);
var WMIServiceStr = "winmgmts:{impersonationLevel=impersonate}!\\\\"
+ strComputer + "\\root\\cimv2";
var objWMIService = GetObject(WMIServiceStr) ;
var nics_query = "SELECT * FROM Win32_NetworkAdapterConfiguration"
+ " WHERE IPEnabled = true";
var nics = objWMIService.ExecQuery(nics_query);
for ( var items=new Enumerator(nics); !items.atEnd(); items.moveNext() ) {
//intNetBT = nic.SetTCPIPNetBIOS(DISABLED) ;
var nic=item.item();
// WScript.Echo("Before Nic NetBIOS: " + item.TcpipNetbiosOptions);
nic.SetTcpipNetbios(ACTION);
// WScript.Echo("After Nic NetBIOS: " + item.TcpipNetbiosOptions);
}
</source>
[[User:Dad|Dad]] 13:38, 12 May 2009 (CEST)