group policy scripts

mishalk
mishalk used Ask the Experts™
on
hi
i have a file called tns.ora which i want to replace and keep the new tns.ora in  in all users
 c:/oranet. how can i do this using a script through group policy.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
Use the "rename" command. It works for files & directories:

Ren tns.ora tns.ora.old

Then use something like xcopy to copy the new version down.

XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W]
                           [/C] [/I] [/Q] [/F] [/L] [/G] [/H] [/R] [/T] [/U]
                           [/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z] [/B]
                           [/EXCLUDE:file1[+file2][+file3]...]

Use the good ol' fashioned xcopy /? to get more detail.


Lee OsborneSenior Infrastructure Engineer

Commented:
If the domain users have write permission to the folder in question, you can create a GPO logon script for the users, and paste this code into a new batch file -

xcopy /y "\\servername\folder\tns.ora" "c:\oranet\tns.ora" >nul

Put this batch file reference as a logon script in -

GP MMC > User Configuration > Policies > Windows Settings > Scripts > Logon

Lee
Lee OsborneSenior Infrastructure Engineer

Commented:
Sorry, forgot you wanted to keep the existing file too!

rename c:\oranet\tns.ora tns.ora.old
xcopy /y "\\servername\folder\tns.ora" "c:\oranet\tns.ora" >nul

Lee
How to Generate Services Revenue the Easiest Way

This Tuesday! Learn key insights about modern cyber protection services & gain practical strategies to skyrocket business:

- What it takes to build a cloud service portfolio
- How to determine which services will help your unique business grow
- Various use-cases and examples

Author

Commented:
rename c:\orant\NET80\ADMIN\TNSNAMES.ORA TNSNAMES.ORA.old
xcopy /y "\\192.168.1.24\Oracle TNSname update\TNSNAMES.ORA" "c:\orant\NET80\ADMIN\TNSNAMES.ORA" >nul



this is the exact script and the location, what is happening is it is renaming the file but not copying to the folder,  i tried running it manually ,but it is doing it

Author

Commented:
sorry
but it is not doing it
Commented:
i did with copy and removed /y it worked

Author

Commented:
after removing the /y and instead of xcopy , i used copy

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial