MichaelWassell
(Fresh Scripter)
2004-02-17 03:24 PM
Enumerate entire network & shutdown

Hello Everyone;

I'm sure that this would only take a few lines of code but I thought I would post it here for anyone with a better idea. I am in need of a script that will enumerate every netbios name on an internal network and execute the shutdown command for each pc enumerated.

I am going to be trying to put something together myself but it would be interesting to see what others have to say


Howard Bullock
(KiX Supporter)
2004-02-17 03:49 PM
Re: Enumerate entire network & shutdown

You could enumerate the names using NetView2() UDF. You then could use SHELL to execute shutdown.exe.

Sealeopard
(KiX Master)
2004-02-17 04:04 PM
Re: Enumerate entire network & shutdown

Something like this?
Code:

dim $iRC

; set restrictive script settings
$iRC=SETOPTION('Explicit','on')
$iRC=SETOPTION('NoVarsInStrings','on')

dim $asCompList, $sComp

$asCompList=NetView2()

? 'Shutting down '+ubound($asCompList)+' computers'

for each $sComp in $asCompList
if $sComp<>@WKSTA
? 'Shutting down '+$sComp
$iRC=SHUTDOWN ($sComp, 'Scheduled network-wide computer shutdown', 10, 1, 0)
endif
next

$sComp=@WKSTA
? 'Shutting down '+$sComp
$iRC=SHUTDOWN ($sComp, 'Scheduled network-wide computer shutdown', 10, 1, 0)
exit 0