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
208 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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 to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

706 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now