VBScribt to copy and overwrite .ini files

I am getting ready to make a system change that will require updates to 3 different .ini files on about 400 PC's. Since nobody on my network has local admin rights, the users can't make the changes. I thought a login script would be the best way to do it. Can someone help me out with a VBScript that would take the new .ini files from a share and overwrite the existing .ini files located in C:\%systemroot%?
LVL 2
seaquist1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NARobertsCommented:
If I'm correct, a login script would run as the users rights (still not able to do the change).  You may need to do an Active Directory "Startup" script.  This should then run as the local system.  ini files are just simple text files.  You should be able to just use a easy write.  Let me see what I got.
0
NARobertsCommented:
Try this.  

Dim fso, MyFile
Dim Input
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.CreateTextFile("c:\testfile.txt", True)
Input = InputBox("Enter text to be written to testfile.txt")
MyFile.WriteLine(input)
MyFile.Close

Should overwrite anything existing I think.
0
NARobertsCommented:
Oh wait, this may be better.  It will actually copy a file over (should be less code!).

Dim FSO, WSH, WSHNetwork

   
   Set FSO = CreateObject("Scripting.FileSystemObject")
   Set WSH = CreateObject("WScript.Shell")
'copy notes data to pc
   FSO.CopyFile "P:\lotus\notes.ini","c:\lotus\notes\notes.ini"
   FSO.CopyFile "P:\lotus\data\names.nsf","c:\lotus\notes\data\names.nsf"
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

seaquist1Author Commented:
The script is trying to work,but I am getting a permissions error. I am using Active Direcory to run andI have it set as a startup script under, I have even tried as a logon script under User settings. Is there a way to have it run with elevated privelages?
0
NARobertsCommented:
Hmmm....not sure about that.  I would have thought that the local system could make that update.  
0
NARobertsCommented:
Found this.  May work but looks rather involved!

http://www.tek-tips.com/faqs.cfm?fid=2760
0
seaquist1Author Commented:
I was able to aswer my own question. Here is the script I used. Please leave this posted for future reference.


Option Explicit

Dim objFSO, objFileCopy, objFileDelete
Dim strFilePath1, strDestination1, strFilePath2, strDestination2


strFilePath1 = "\\Domain Controller\sysvol\domainname.local\scripts\saplogon.ini"
strFilePath2 = "\\Domain Controller\sysvol\domainname.local\scripts\services"
strDestination1 ="C:\WINDOWS\saplogon.ini"
strDestination2 ="C:\WINDOWS\system32\drivers\etc\services"

Set objFSO = CreateObject("Scripting.FileSystemObject")

'******************************************************************
'*         This section deletes the existing saplogon.ini         *
'*               and then copies the new one down                 *
'******************************************************************

' Deleting
Set objFileCopy = objFSO.GetFile(strDestination1)
objFileCopy.Delete ()

'Getting the file
Set objFileCopy = objFSO.GetFile(strFilePath1)

' Copying
objFileCopy.Copy (strDestination1)

'******************************************************************
'*         This section deletes the existing services file        *
'*               and then copies the new one down                 *
'******************************************************************

'Deleting
Set objFileCopy = objFSO.GetFile(strDestination2)
objFileCopy.Delete ()

'Getting the FIle
Set objFileCopy = objFSO.GetFile(strFilePath2)

' Copying
objFileCopy.Copy (strDestination2)
' End of example Script
0
seaquist1Author Commented:
PAQ it. I posted this request when I answered my own question (right above the admin comment). Sorry I did this in the wrong spot.


I was able to aswer my own question. Here is the script I used. Please leave this posted for future reference.


Option Explicit

Dim objFSO, objFileCopy, objFileDelete
Dim strFilePath1, strDestination1, strFilePath2, strDestination2


strFilePath1 = "\\Domain Controller\sysvol\domainname.local\scripts\saplogon.ini"
strFilePath2 = "\\Domain Controller\sysvol\domainname.local\scripts\services"
strDestination1 ="C:\WINDOWS\saplogon.ini"
strDestination2 ="C:\WINDOWS\system32\drivers\etc\services"

Set objFSO = CreateObject("Scripting.FileSystemObject")

'******************************************************************
'*         This section deletes the existing saplogon.ini         *
'*               and then copies the new one down                 *
'******************************************************************

' Deleting
Set objFileCopy = objFSO.GetFile(strDestination1)
objFileCopy.Delete ()

'Getting the file
Set objFileCopy = objFSO.GetFile(strFilePath1)

' Copying
objFileCopy.Copy (strDestination1)

'******************************************************************
'*         This section deletes the existing services file        *
'*               and then copies the new one down                 *
'******************************************************************

'Deleting
Set objFileCopy = objFSO.GetFile(strDestination2)
objFileCopy.Delete ()

'Getting the FIle
Set objFileCopy = objFSO.GetFile(strFilePath2)

' Copying
objFileCopy.Copy (strDestination2)
' End of example Script
0
NARobertsCommented:
Sorry my suggestions couldn't be of any help to you.  Glad you fixed it.
0
GranModCommented:
PAQed with points refunded (500)

GranMod
Community Support Moderator
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
maximal81Commented:
Oke i had everything done ok, but i think it was not possible to get a file from a normal share (is this true?), it is only possible from the sysvol share of AD where the scripts are posted \Domain name\\sysvol\domainname.local\scripts\

Thanx for the nice script,
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.