MartyConnelly
martyconnelly at shaw.ca
Thu Nov 18 20:40:55 CST 2004
Or try here for usenet definition http://www.comedia.com/hot/jargon-4.2.3/html/entry/BOFH.html Joe Hecht wrote: >I will bite. BOFH? > >JOE HECHT >LOS ANGELES CA > jmhla at earthlink.net > >-----Original Message----- >From: accessd-bounces at databaseadvisors.com >[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of MartyConnelly >Sent: Thursday, November 18, 2004 5:51 PM >To: Access Developers discussion and problem solving >Subject: [AccessD] For Trainee BOFH's > > Those of you working on your BOFH certification might find this piece >of code useful >Or if you really want to get all those users out of your database so you >can work on it. >Or if you really want to renew a dhcp lease. > >You can run from vbs or Access VBA > >Here's a way to reboot a list of systems with a single keystroke. >Replace the contents of the code between "Else" and "End if" statements >in the script below that (renews DHCP leases on all computers) with >the following: > > Set colOperatingSystems = objWMIService.ExecQuery("Select * from >Win32_OperatingSystem") > objTextFile.WriteLine(strComputer & " is rebooting.") > For Each objOperatingSystem in colOperatingSystems > ObjOperatingSystem.Reboot() >Next > > >'computer.txt' is a file that contains a list of all network machine names >' well aside from your own. > >RebootFile = "computers.txt" >LogFile = "results.txt" > >Set fso = CreateObject("Scripting.FileSystemObject") >Set f = fso.OpenTextFile(RebootFile, 1, True) >Set objTextFile = fso.OpenTextFile(LogFile, 2, True) > >On Error resume next >Do While f.AtEndOfLine <> True > strComputer = f.ReadLine >Set objWMIService = GetObject("winmgmts:" & >"{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") >If Err.Number <> 0 Then > objTextFile.WriteLine(intCount & ". " & strComputer & " is not >responding.") > Err.Clear >Else >Set objNetworkSettings = >objWMIService.Get("Win32_NetworkAdapterConfiguration") > objNetworkSettings.RenewDHCPLeaseAll() > objTextFile.WriteLine(strComputer & " has been renewed.") >End If >Loop > > > -- Marty Connelly Victoria, B.C. Canada