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
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
216 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
  • 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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
kerberos errors 7 552
Window 2000 server in a SBS2011 domain DNS Errors 4 468
Outlook 2013 Certicate error 1 296
Using VBScript. How to obtain the recomended paging file size? 8 70
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…
Learn how to PXE Boot both BIOS & UEFI machines with DHCP Policies and Custom Vendor Classes
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

856 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