Solved

2003 server I need a script that will copy an .ini file to all of my users machines.

Posted on 2003-12-05
8
218 Views
Last Modified: 2010-04-13
I need a script that will copy an .ini file to all of my users machines.
I need this file to be copied to all the machines in the domain only once.
Im working on my scripting skill but this needs to be done by monday and i dont want to
goto each machine and do it. Thanks for the help.
0
Comment
Question by:djohnson104
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 1

Accepted Solution

by:
20LILY00 earned 100 total points
ID: 9883815
This will give you an idea. This script keeps track of computers that login and places a file on there machine only once. If the file exsists it wont rerun the next time they log in.


Public FileExists,proc,comp

FileExists=0





Call ReportFileStatus()



if FILEEXISTS =0 then

      Call fncOpenTextFileTest(err)

      Call EndProcess (Proc, comp)
END IF





Function fncOpenTextFileTest(err)

      On Error Resume Next

      Set WshNetwork = WScript.CreateObject("WScript.Network")

         Set fso = CreateObject("Scripting.FileSystemObject")

        Set f = fso.OpenTextFile("\\lilynorth\printerLog$\Printer.txt", ForAppending, True)

      Const ForReading = 1, ForWriting = 2, ForAppending = 8

         Dim f,fso


      If err<>0 then
            fncSendMessage()
      Else
      
            FSO.CopyFile "\\fido\netlogon\deleteThis.txt", "c:\"
      END IF

         
 
         f.Write WshNetwork.ComputerName & "  " & WshNetwork.UserName & " " & err & " " & date

         f.WriteBlankLines(1)

         f.Close
   
End Function





Function ReportFileStatus()

      On Error Resume Next
      
        Dim fso, msg,filespec

         filespec= "c:\deleteThis.txt"

        Set fso = CreateObject("Scripting.FileSystemObject")

        If (fso.FileExists(filespec)) Then

                FileExists=1

         Else

                  FileExists=0
      End If
   
End Function



'*** Makes sure all processes are closed **********

      Function EndProcess (Process, computername)

            Dim obj

            comp = WScript.CreateObject("WScript.Network").ComputerName

              For Each obj In GetObject("winmgmts://" & computername & _
                    "/root/cimv2").ExecQuery("SELECT * FROM Win32_Process")

                If lcase(obj.Description) = lcase(Process) Then obj.Terminate
              Next
      
              Set obj = Nothing

      End Function


0
 
LVL 2

Author Comment

by:djohnson104
ID: 9883941
Thanks alot but im not sure what to do with it. If you could just sum up what i need to do that would be great!!
0
 
LVL 1

Expert Comment

by:20LILY00
ID: 9884791
I have edited the script so all you should have to do is put in the file name and location in 2 places im sure you can figure that out.



Public FileExists,proc,comp

FileExists=0





Call ReportFileStatus()



if FILEEXISTS =0 then

      Call fncOpenTextFileTest(err)

      Call EndProcess (Proc, comp)
END IF





Function fncOpenTextFileTest(err)

      On Error Resume Next

      Set WshNetwork = WScript.CreateObject("WScript.Network")

         Set fso = CreateObject("Scripting.FileSystemObject")

        

         Dim f,fso


      If err<>0 then
            fncSendMessage()
      Else
      
            FSO.CopyFile "\\FILE LOCATION HERE\netlogon\Name of ini.ini", "c:\"
      END IF

         
         f.Close
   
End Function





Function ReportFileStatus()

      On Error Resume Next
      
        Dim fso, msg,filespec

         filespec= "c:\Name of ini.ini"

        Set fso = CreateObject("Scripting.FileSystemObject")

        If (fso.FileExists(filespec)) Then

                FileExists=1

         Else

                  FileExists=0
      End If
   
End Function



'*** Makes sure all processes are closed **********

      Function EndProcess (Process, computername)

            Dim obj

            comp = WScript.CreateObject("WScript.Network").ComputerName

              For Each obj In GetObject("winmgmts://" & computername & _
                    "/root/cimv2").ExecQuery("SELECT * FROM Win32_Process")

                If lcase(obj.Description) = lcase(Process) Then obj.Terminate
              Next
      
              Set obj = Nothing

      End Function


0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 1

Expert Comment

by:20LILY00
ID: 9884812
Oh and just referance this script file in a login script
0
 
LVL 2

Author Comment

by:djohnson104
ID: 9885023
Worked like a charm thanks for the help.

Your points are awarded

Where can i put this so it will affect the whole domain?
Do i have to add it to each user under there profile?

Thanks again
0
 
LVL 1

Expert Comment

by:20LILY00
ID: 9885054
Well yes or you could probably create a policy and apply it .
0
 
LVL 2

Author Comment

by:djohnson104
ID: 9885223
I just found out where to do that thanks alot for your help
0

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
After seeing many questions for JRNL_WRAP_ERROR for replication failure, I thought it would be useful to write this article.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question