batch file

Hi

We have 60 computer plus and we are using CA for deploying hot fixes and service packs.

The CA server (this server releases the updates has record of all the machines) has recently died so I have replaced it with new CA server. Now I have to run the below command through CMD using specific domain admin account to point all the machines to this new server so that they receive updates:

caf setserveraddress servername


Can anyone help me to create a batch file so that I can link it with GPO in the windows 2008 server.

I really need some help.  
LVL 7
mcse2007Asked:
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.

BALMUKUND KESHAVCommented:
Batch file is nothing but a text file with extension .bat
You simply make a text file in any text editor and make the extension of the .bat
@ Command prompt type the following :
Copy Con Yourbatfilename.bat
Type your command here
Press Ctrl+Z

This will make a batch file.
To run a batch file : Simply Click on Batchfilename in Windows or in DOs CMD propmpt type batchfilename.bat and press enter.

Bm keshav
0
StuartMc77Commented:
Create a text file on your desktop called whatever you like.
Type the following into the text file:

@echo off
caf setserveraddress servername

Save the file and close it.

Rename the file from "whatever.txt" to "whatever.bat"

put it where you need to on the server and do what you need to with the GPO.

Hope that helps.
0
mcse2007Author Commented:
Bm keshav, your suggestions shoudn't be an issue do to which I'm already quite familiar with, thank you.

StuartMc77, the command has to run on the specific admin account permission which means that the batch file when executed through GPO it has to use specific admin account.
@echo off
caf setserveraddress servername

I tried that and it didn't work, Am I missing something?
0
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

StuartMc77Commented:
you could use the RUNAS command in the batch file but sadly you would then have to type in the password for that admin account on each computer as it boots... I'm not sure if there is a way to run it through GPO as a specific user.

I will look into it for you.
0
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
Would running the command for all live computers from a single point do? I reckon the command has to be applied only once for each computer.
If so, a psexec (www.sysinternals.com) with a list of all computers would work fine, like

psexec @pclist.txt -d -u admin -p adminpwd caf setserveraddress servername


0
Steve KnightIT ConsultancyCommented:
Why does this need to run as a specific admin account if you don't mind me asking?  Would it run OK as the local system, i.e. run it as a startup account instead?  It may also be worth considering seeing what it changes - perhaps taking a snapshot of files/registry entries, it probably only changes a registry entry in HKLM which would be easy then to carry out using a REG or REGEDIT -s command in a startup script.

For only 60 machines you could schedule a task on the remote computers using command line util or use psexec to run a process on a list of machines etc?
0
mcse2007Author Commented:
StuartMc77: - I 've already thought about this and as you've mentioned I have to put in the password

dragon-it: The domain account is the only account that can deploy hot fixes, sps etc., hence it is the only account that has the authority to point all machines to new CA server. The CA (must like WSUS server of Microsoft) is owned by Computer Associates for deploying packages etc., to LAN or WAN infrastructure. I work for a Germany company base in Sydney and unfortunately they are very specific on which domain account to use for deployment.

Qlemo: I tried you susgestion and I'm getting an error - pls see the attached file.
Also, how do I incorporate this into GPO? Since I'm new to psexec, appreciate if you can profit a detail step-by-step instructions pls.

NOTE: I've blanked out some personal info for security reason.
error-cannot-find-the-file-speci.JPG
0
mcse2007Author Commented:
sorry, I meant provide details...my fingers are freezing because it is winter here in sydney at the moment.
0
Steve KnightIT ConsultancyCommented:
Ok fair enough... as from above I think if you read the error you can see what the problem is with psexec?  Where have you put the pclist.txt and did you still have it open in notepad perhaps if it is in c:\.  Was going to suggest psexec solution too though this is one off as Qlemo says you don't need to put this in GPO this runs on a list of computers you have on at a point in time.

Which is why I suggested I'm 100% sure there are easier ways of doing this, i.e. just create a startup script or identify what registry or INI file entry it changes with the new IP address for the relevant computers OU in AD running this as that will run as the computer and therefore effectively admin rights

... but if you are against that not much else I can suggest, sorry.
0
AmazingTechCommented:
Also your pclist.txt is not in the current directory so you should change your directory to where you have psexec.exe and pclist.txt

If your on your workstation can you type in CFA from anywhere? If not you might want ot try running the psexec with the full path to CFA.

Trial 1:
CD /d "%UserProfile%\My Documents\psexec"
psexec @pclist.txt -d -u Admin -p password cfa setserveraddress server1

Trial 2:
CD /d "%UserProfile%\My Documents\psexec"
psexec @pclist.txt -d -u Admin -p password "C:\Program Files\CA\CA_AppSW\cfa" setserveraddress server1
0
mcse2007Author Commented:
Qlemo - that is correct the command should run once only

dragon-it - i'm open for everything until this issue is resolve just tell me precilesly you need me to. I did a search on the INI file and it shows close to 50 INI files and manage to narrow it down to 3 ini files but not sure which one amonght the three.

AmazingTech - i'm getting psexec exited with error code 1. psexec exit......what is this error code 1 means? The command has to include the domain\domain account, using the local admin account will not change the registered servername of the client.
0
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
psexec error codes are those of the application started, psexec itself does not return any status besides the text message.

I would not integrate this into GPO for a one-time action, just start it from a single computer while all (or as much as possible) machines are available.
0
AmazingTechCommented:
I have experience where using the @pclist.txt did not work. Let's try just 1 computer for now until we get a working command line.

Change computer1, doamin\admin, password and server1

Trial 1:
CD /d "%UserProfile%\My Documents\psexec"
psexec \\computer1 -d -u domain\Admin -p password cfa setserveraddress server1

Trial 2:
CD /d "%UserProfile%\My Documents\psexec"
psexec \\computer1 -d -u domain\Admin -p password "C:\Program Files\CA\CA_AppSW\cfa" setserveraddress server1
0
mcse2007Author Commented:
Qlemo - I agree 100%

AmazingTech - Trial 1 works perfect. I tested it also on other pc and it worked. On the other hand, I have above 60 computers to go through so using the 'pclist.txt' is the way to go.

I tried the below command but it is giving me an error like cannot start the PsExec service on computername, Access is Denied.   Will this means I will have the same issue to all 60 computers?

CD /d "%UserProfile%\My Documents\psexec" psexec @pclist.txt  -d -u domain\Admin -p password cfa setserveraddress server1
0
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
The message means you do not have local admin access - as domain admin this is quite strange if the target computers are domain members ...
0
mcse2007Author Commented:
Qlemo - it is bizzare, you're right. You see the Trial 1 works fine BUT when I use 'pclist.txt' the command gets denied.

the pclist.txt contain only one computername, which is the same computer name mentioned from the Trial 1 that did worked.

It will be timing consuming to go through 60 computers one-at-a-time.
0
AmazingTechCommented:
No problem at all. We'll just use a for loop with pclist.txt as long as we now know something that works.

Simple.
CD /d "%UserProfile%\My Documents\psexec"
for /f %%a in (pclist.txt) do psexec \\%%a -d -u domain\Admin -p password cfa setserveraddress server1

Open in new window

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
mcse2007Author Commented:
I'm receiving the below message right after running the above command

%%a was unexpected at this time.
0
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
If not using a batch file, replace %%a by %a in the above code.
0
mcse2007Author Commented:
Thanks AmazingTech and  Qlemo..........you guys are too good!

I modified the command as per Qlemo comments  as shown below then added few more pcs in the 'pclist.txt' with successful result.

CD /d "%UserProfile%\My Documents\psexec"
for /f %a in (pclist.txt) do psexec \\%a -d -u domain\Admin -p password cfa setserveraddress server1
0
AmazingTechCommented:
I'm glad it worked out for you.
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
Microsoft DOS

From novice to tech pro — start learning today.