I'm sure this is possible but im very new to VBScript so im kinda lost and im hoping someone can help me with it.
Im trying to use the script below to write this file to a list of computers. I would like to have it read a list of computer names from a text and insert it where it says computer name. And to top it off i would like it to rite a list of computer names to a txt file that it could not connect to. Any ideas?
Set FSO = CreateObject("Scripting.FileSystemObject") Set Destination = fso.CreateTextFile ("\\Computername\C$\Documents and Settings\All Users\Desktop\Find My Service Tag", True) Destination.WriteLine Set WshNetwork = WScript.CreateObject("WScript.Network") Destination.WriteLine WScript.Echo "Service Tag = " & WshNetwork.ComputerName Destination.Close
here's a better start, or search the forum or google. I suppose if you lookup ping you will find better examples[I have a few just lazy to lookk right now]
_____________________________
"You start coding. I'll go find out what they want."
I couldnt get this to work. It looks like it might be reading the txt file but not writing anyting. any idea waht im doing wrong. Here is the code i was working with.
Option Explicit 'Declare variables Dim strComputer Dim arrComputers Dim TxtFile Dim objTextFile Dim strNextLine Dim objLogFile Dim OverwriteExisting Dim WshShell : Set WshShell = CreateObject("Wscript.Shell") Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject") Dim WshSysEnv : Set WshSysEnv = WshShell.Environment("Process") Dim SysDrive : SysDrive = WshShell.ExpandEnvironmentStrings("%SYSTEMDRIVE%") Dim SourceL:SourceL = "C:\test.txt" ----- this is the file i would like ti to copy Dim LogFile:LogFile = sysDrive & "\Filelog.txt" Dim DestFile:DestFile = "C:\test.txt" On Error Resume Next Const ForAppending = 8 Const ForReading = 1 TxtFile = sysDrive & "\wslist.txt" ----I put this file in the root and i think it is supposed to contain the computer names
'Copy & verify file Set objLogFile = objFSO.OpenTextFile(LogFile, 8, true) Set objTextFile = objFSO.OpenTextFile (TxtFile, 1) TxtFile = objTextFile.ReadAll objTextFile.Close objLogFile.Close arrComputers = Split(TxtFile, vbCrLf) For Each strComputer in arrComputers Wscript.Echo strComputer objFSO.CopyFile SourceL & DestFile, "\\"& strComputer & "\c$\", OverwriteExisting If objFSO.FileExists(SysDrive & "\" & DestFile) Then objLogFile.Write strComputer objLogFile.WriteLine Else objFSO.CopyFile SourceL , SysDrive & "\", True End If Next
'Clean up & quit Set objFSO = Nothing Set objTextFile = Nothing
thanks again for you help
< Message edited by jcarver_14 -- 6/10/2008 1:59:48 AM >
Come on now. I thought this was going to be a fairly simpe one. And after 108 hits and 3 replies I realized I wasnt getting any help so I asked one of my good friends for help, a network manager, thats right network... not programer, and he helped me. But sense noone here cares to help I will post the script I came up with, maybe it will help someone....
In case your like me and you dont know much about vbs heres how this works and what you need to do.
How it works:
This reads a list of computer names from a txt file. It then pings each one. If it does not ping it writes the computer name to a txt file called Failed.txt. If it does ping it will copy the file you specify to the destination you specified on the computer then write the computer name to a text file named Completed.txt.
What you need to do:
Because this script works out of a folder you will need to create a folder for it. ex. Copy Files... and place the script into it. Then create a txt file named Computer Names.txt inside the same folder and enter the computer names into it. Open the vbs script for editing. you will need to edit line 21. If you can place the file to be copied into the folder as well that works great. Just replace %file% with the file name. be sure to include the extention. If you would like to keep the folder in its location just replace it with the path. ex. C:\folder\test.txt. Then you will need to edit the destination. it is curently set to \\computername\C$\ and is in line 21 as well. When the script has finished it will display a messsage box letting you know.