Difference between revisions of "Talk:Enable/disable NetBIOS over TCP/IP"
From WPKG | Open Source Software Deployment and Distribution
(Add an alternative implementation to configure netBIOSoverTcpip) |
(change the error in the js) |
||
| Line 41: | Line 41: | ||
} else if (argv.Exists("default")){ | } else if (argv.Exists("default")){ | ||
ACTION = DEFAULT; | ACTION = DEFAULT; | ||
| − | } else if (argv.Exists("help") | + | } else if (argv.Exists("help") || (argv.Exists("?"))) { |
showUsage(); | showUsage(); | ||
exit(0); | exit(0); | ||
| Line 62: | Line 62: | ||
for ( var items=new Enumerator(nics); !items.atEnd(); items.moveNext() ) { | for ( var items=new Enumerator(nics); !items.atEnd(); items.moveNext() ) { | ||
//intNetBT = nic.SetTCPIPNetBIOS(DISABLED) ; | //intNetBT = nic.SetTCPIPNetBIOS(DISABLED) ; | ||
| − | var nic= | + | var nic=items.item(); |
// WScript.Echo("Before Nic NetBIOS: " + item.TcpipNetbiosOptions); | // WScript.Echo("Before Nic NetBIOS: " + item.TcpipNetbiosOptions); | ||
nic.SetTcpipNetbios(ACTION); | nic.SetTcpipNetbios(ACTION); | ||
Latest revision as of 08:46, 15 September 2011
I propose an alternative to setNetBIOSoverTCPIP.vbs, I implement it in Jscript. It support arguments:
cscript ConfigNetBIOSoverTcpip.js /enable cscript ConfigNetBIOSoverTcpip.js /disable cscript ConfigNetBIOSoverTcpip.js /default
ConfigNetBIOSoverTcpip.js
// 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") || (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=items.item();
// WScript.Echo("Before Nic NetBIOS: " + item.TcpipNetbiosOptions);
nic.SetTcpipNetbios(ACTION);
// WScript.Echo("After Nic NetBIOS: " + item.TcpipNetbiosOptions);
}
Dad 13:38, 12 May 2009 (CEST)