We help IT Professionals succeed at work.

batch file

mcse2007
mcse2007 asked
on
856 Views
Last Modified: 2012-05-07
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.  
Comment
Watch Question

CERTIFIED EXPERT

Commented:
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
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.

Author

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?
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.
Qlemo"Batchelor", Developer and EE Topic Advisor
CERTIFIED EXPERT
Top Expert 2015

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


Steve KnightIT Consultancy
CERTIFIED EXPERT

Commented:
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?

Author

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

Author

Commented:
sorry, I meant provide details...my fingers are freezing because it is winter here in sydney at the moment.
Steve KnightIT Consultancy
CERTIFIED EXPERT

Commented:
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.
Top Expert 2009

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

Author

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.
Qlemo"Batchelor", Developer and EE Topic Advisor
CERTIFIED EXPERT
Top Expert 2015

Commented:
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.
Top Expert 2009

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

Author

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
Qlemo"Batchelor", Developer and EE Topic Advisor
CERTIFIED EXPERT
Top Expert 2015

Commented:
The message means you do not have local admin access - as domain admin this is quite strange if the target computers are domain members ...

Author

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.
Top Expert 2009
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
I'm receiving the below message right after running the above command

%%a was unexpected at this time.
Qlemo"Batchelor", Developer and EE Topic Advisor
CERTIFIED EXPERT
Top Expert 2015
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

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
Top Expert 2009

Commented:
I'm glad it worked out for you.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.