Solved

batch file

Posted on 2009-07-02
21
764 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.  
0
Comment
Question by:mcse2007
  • 8
  • 4
  • 4
  • +3
21 Comments
 
LVL 6

Expert Comment

by:BALMUKUND KESHAV
ID: 24762200
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
 
LVL 1

Expert Comment

by:StuartMc77
ID: 24762210
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
 
LVL 7

Author Comment

by:mcse2007
ID: 24762269
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
 
LVL 1

Expert Comment

by:StuartMc77
ID: 24762364
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
 
LVL 68

Expert Comment

by:Qlemo
ID: 24764975
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
 
LVL 43

Expert Comment

by:Steve Knight
ID: 24764985
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
 
LVL 7

Author Comment

by:mcse2007
ID: 24768583
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
 
LVL 7

Author Comment

by:mcse2007
ID: 24768597
sorry, I meant provide details...my fingers are freezing because it is winter here in sydney at the moment.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 24770172
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
 
LVL 21

Expert Comment

by:AmazingTech
ID: 24770787
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 7

Author Comment

by:mcse2007
ID: 24771966
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
 
LVL 68

Expert Comment

by:Qlemo
ID: 24772566
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
 
LVL 21

Expert Comment

by:AmazingTech
ID: 24772822
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
 
LVL 7

Author Comment

by:mcse2007
ID: 24774908
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
 
LVL 68

Expert Comment

by:Qlemo
ID: 24774918
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
 
LVL 7

Author Comment

by:mcse2007
ID: 24775019
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
 
LVL 21

Accepted Solution

by:
AmazingTech earned 200 total points
ID: 24776211
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
 
LVL 7

Author Comment

by:mcse2007
ID: 24776635
I'm receiving the below message right after running the above command

%%a was unexpected at this time.
0
 
LVL 68

Assisted Solution

by:Qlemo
Qlemo earned 200 total points
ID: 24776705
If not using a batch file, replace %%a by %a in the above code.
0
 
LVL 7

Author Closing Comment

by:mcse2007
ID: 31599134
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
 
LVL 21

Expert Comment

by:AmazingTech
ID: 24779062
I'm glad it worked out for you.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now