Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


noobie needs help with first script :?

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,1803
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> noobie needs help with first script :?
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 noobie needs help with first script :? - 1/8/2005 10:28:48 AM   
  zimmerframe

 

Posts: 1
Score: 0
Joined: 1/8/2005
From:
Status: offline
Hi all, I'm new to this forum and I am joining in hope to find some help with my first script.

I am working as a network support officer for a company I have worked with for some time.
I am the only guy here that supprots the IT gear we have and I usually find it hard to overcome the challenges assigned to me when new developments arise.
Just recently I have been instructed to produce a report every day of the workstations on my network that are left turned on overnight. The network I have just recently upgraded to a Windows 2k3 AD Domain and I have considered using VB script to make my network better.
Does anyone know of and good resources or even better, an example of, the sort of script I need to rwrite.

I have thought of making a script to use Ping.exe to ping all my statically assigned IP address workstations and generate a text file with all the reachable workstations?

Would this be the right was of going about this sort of task?

Any help would be greatly appreciated.

Cheers.
 
 
Post #: 1
 
 Re: noobie needs help with first script :? - 1/8/2005 10:32:33 AM   
  nstraub

 

Posts: 7
Score: 0
Joined: 12/15/2004
From:
Status: offline
maybe it would be better to use wmi to connect to the pcs every day at a certain time and ask them to find any shutdown event in the pc's event log. Unfortunnatly I can't give you any code cause I just begun learning wmi but at least I think you should start there

(in reply to zimmerframe)
 
 
Post #: 2
 
 Re: noobie needs help with first script :? - 1/8/2005 12:02:27 PM   
  tnoonan

 

Posts: 364
Score: 0
Joined: 12/14/2004
From:
Status: offline
Here you go. Edited from another script I had to change admin password on local box all pc's on domain. You should have one local account on every box that is the same. Here i'm using Administrator account. Just make sure you change the email settings at the end.

'-------------------------------------------------------------------------------
' Initialization - Declare variables
'-------------------------------------------------------------------------------
Dim MyVar
Dim objOutlook
Dim objNameSpace
Dim mItem
Dim strCarbonCopy
Dim strBCC
Dim strReceipient
Dim strSubject
Dim strBodyText
Dim strMsg
Dim pAttachment
Dim strAttach
Dim DnameObj,objContainer,colPCs,objEnv,objDomain
Dim isnew,fso
dim message,dname
Dim fsoIn,fsoOut
Dim inFile,outFile,outExist,outExist2
Dim arrComputerNames
Dim objUser
Dim strComputer
Dim ErrorOccurred
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Const inFilename = "PCList.txt"
Const outFileExist = "PCList.txt"
Const outFilename = "Online.txt"
Const outFileExist2 = "Online.txt"
Set WshShell = WScript.CreateObject("WScript.Shell")

'-------------------------------------------------------------------------------
'Get current Domain
'-------------------------------------------------------------------------------
key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\Currentversion\Winlogon\CachePrimaryDomain"
dname = WshShell.RegRead (key)


set objEnv = WshShell.Environment("process")
dname = objEnv("USERDOMAIN")
on error resume next

'Bind to the builtin administrators group to see if you can connect
GetObject("WinNT://" & dname &"/administrators")
if err.number then
message = "Cannot bind to " &dname
WshShell.Popup message,0,"Connection or Authority Failure",vbCritical
WScript.Quit
End If

DnameObj = "WinNT://" & dname
WshShell.Popup "Please Stand By.....",3,"Query Domain",64
Set objContainer=GetObject(DnameObj)
objContainer.Filter=Array("computer")
Set fso = CreateObject("scripting.filesystemobject")

'-------------------------------------------------------------------------------
'List creation from active directory or User created ?
'-------------------------------------------------------------------------------

If (MsgBox("Do you want to create a list from active directory ? " &_
"", vbYesNo + vbQuestion,"www.spoogenet.com") = vbYes) Then
List

Else

message = message & "You need to type in you computer names and save file when completed"
WshShell.Popup message,0,"www.spoogenet.com",vbInformation
WshShell.Run "notepad PCList.txt"

End If

'-------------------------------------------------------------------------------
'If file exists delete and create from active directory
'-------------------------------------------------------------------------------
Sub List()
If (Not fso.FileExists(outFileExist)) Then
isnew = True
Else
isnew = False
End If

If isnew = False Then
fso.DeleteFile(outFileExist)
End If
Set outExist = fso.OpenTextFile(outFileExist, ForAppending, True)

For Each colPCs in objContainer
outExist.writeline colPCs.Name

Next

If (MsgBox("Done. All PCs in " & dname & " exported to " & outFileExist &_
". " & vbCrLf & "Open file " & outFileExist & " ?",_
vbYesNo + vbQuestion,"www.spoogenet.com") = vbYes) Then
WshShell.Run "notepad PCList.txt"

End If

If (Not fso.FileExists(outFileExist2)) Then
isnew = True
Else
isnew = False
End If

If isnew = False Then
fso.DeleteFile(outFileExist2)
End If
Set outExist2 = fso.OpenTextFile(outFileExist, ForAppending, True)

For Each colPCs in objContainer
outExist.writeline colPCs.Name

(in reply to zimmerframe)
 
 
Post #: 3
 
 Re: noobie needs help with first script :? - 1/10/2005 12:26:12 AM   
  mbouchard


Posts: 1916
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
Here is a script that I used to ping a list of PC's and check their status.


      

(in reply to zimmerframe)
 
 
Post #: 4
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> noobie needs help with first script :? Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts