Looking for a script

im looking for a script,

I have a folder, which needs to be copied 100+ servers, and in that a folder I have bat file needs to be executed and it will generate CSV file.
and again all the CSV files needs to be copied back to source.

All servers are in workgroup, not in a domain, uses the same password and user id.

environment windows 2008 r2 std and enterprise

Appreciate your help.. Thanks
bsarahimAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

Adam LeinssServer SpecialistCommented:
How about 3 scripts?

One to copy:

FOR /F "delims=" %%i IN (computers.txt) DO (
 mkdir \\%%i\c$\temp
 xcopy *.* "\\%%i\c$\temp"
)

Open in new window


One to run batch file (download psexec for this):

psexec @computers.txt C:\temp\file.bat

Open in new window


One to copy the data back:

FOR /F "delims=" %%i IN (computers.txt) DO (
 xcopy "\\%%i\c$\temp\*.csv" C:\TEMP
)

Open in new window

1

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
bsarahimAuthor Commented:
Thanks

1. How it will logon to all servers?
2. Incase of any failure, will it halt and have error generated and recorded?

3. FOR /F "delims=" %%i IN (computers.txt) DO (
 mkdir \\%%i\c$\temp
 xcopy *.* "\\%%i\c$\temp"
)

will it read line by line of Computer.txt ?
0
Adam LeinssServer SpecialistCommented:
1. You said the login and password is the same on all machines, so it should use NTLM pass-through authentication to connect to each machine.  When you run the script: you will have to be logged in with this same account and password or the connection to remote machines will fail.

2. It will record the errors to the console from which you run the script interactively.  If you want the results to a file you can re-direct it such as
copyfiles.cmd > copyfiles.log

Open in new window


3. Yes

Start with one computer and test the results.
0
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

bsarahimAuthor Commented:
Thanks a lot..
and also, im planning to execute this script for Domain users for few machines which are in domain, but user id and pwd is same.. (I will not be using Group policy, as due to some rights issue)

will the above script will work?
0
Adam LeinssServer SpecialistCommented:
As long as the script is ran under an account that has admin rights to the remote machines it should work.
0
bsarahimAuthor Commented:
hi adam, im getting a error. pls have a look and suggest.. Thanks

in computers.txt file i have the hostnames
error1.png
0
Adam LeinssServer SpecialistCommented:
Change

computers.txt

Open in new window

to

C:\testing\computers.txt

Open in new window


and then try it
0
bsarahimAuthor Commented:
Thanks.. but still not working..
0
bsarahimAuthor Commented:
sorry attached the screenshot of error .. Thanks
error2.png
0
Adam LeinssServer SpecialistCommented:
I bet the filename is computers.txt.txt.  Do a dir in your command line and see if it shows computers.txt.txt.  If so, rename it to computers.txt and then change the script back to just computers.txt.

You might want to turn on "Show file extensions" in your Windows explorer as well.
0
bsarahimAuthor Commented:
Thanks a lot for your wonderful support, you are right.. and it worked.. but i have error in the step2

appreciate your help on this..attached the screenshot
0
bsarahimAuthor Commented:
error screen
error3.png
0
Adam LeinssServer SpecialistCommented:
Program Files has a space in the path, so you have to put quotes around it:

"C:\program files\hcl\hchlauncher_win\HCLauncher\cscript-1.bat"
0
bsarahimAuthor Commented:
Thanks a lot, it works..

but i need to execute the below..

psexec @computers.txt -c -f -s -d "c:\Program Files\HCL\HCLauncher_Win\HCLauncher\cscript INSTALL.Vbs Windows.2008.CSD.pol"

it says path is not found and i tired with out quotes as well

and install.vbs should be under program files folder
erro4.png
0
Adam LeinssServer SpecialistCommented:
Your best bet is to put a command line in a batch file, copy that to the remote computer and then execute that batch file with psexec.

For the above example you could put:

C:\windows\system32\cscript.exe "c:\Program Files\HCL\HCLauncher_Win\HCLauncher\INSTALL.Vbs Windows.2008.CSD.pol"

Open in new window


Ideally, you want to try this command line by hand first on one of these machines.  Once you get a working command line, throw that into a batch file, then copy that batch file to the remote machines and then fire that batch file with psexec.
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
Shell Scripting

From novice to tech pro — start learning today.