myITforum.com Community Forum myITforum.com Community Forum

Home  Forums  Blogs  Live Support chat  Search Articles  Wiki  FAQ  Email Lists  Register  Login  My Profile  Inbox  Address Book  My Subscription  My Forums 

Photo Gallery  Member List  Search  Calendars  FAQ  Ticket List  Log Out

All Forums RSS Feed Subscription:


  


Having problems scripting Netdom to rename systems

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
  Printable Version
All Forums >> [Scripting Technologies] >> General Scripting >> Having problems scripting Netdom to rename systems Page: [1]
Login
Message << Older Topic   Newer Topic >>
Having problems scripting Netdom to rename systems - 8/19/2008 6:33:55 PM   
swood

 

Posts: 473
Score: 5
Joined: 12/6/2001
Status: offline
I'm running a batch file to rename a system - the command looks like

for /f "delims= tokens=1" %%a IN currentname.txt DO Netdom RenameComputer
%computername%  /NewName: %%a  /UserD:mydomain\admin  /PasswordD:mypassword

I have a computer name called in currentname.txt which I want to fill in after /NewName. When I run the command it looks like this...

for /f "delims= tokens=1" %a IN currentname.txt DO netdom RenameComputer OLDCOMPUTER /NewName:%a /UserD:domain\admin /passwordD:password

I can't figure out why the script doesn't pull the text value from the text file and instead return %a.
--
Sandy Wood
Orange County District Attorney

_____________________________

Sandy Wood
Network Admin
Orange County District Attorney
Post #: 1
RE: Having problems scripting Netdom to rename systems - 8/19/2008 8:33:22 PM   
jsandys


Posts: 527
Score: 17
Joined: 3/24/2005
From: San Antonio, TX
Status: offline
Are you running the FOR command from a command line to test it? If so, the syntax is slightly different: from a command line you use %variable, in a batch file you use %%variable.


_____________________________

Jason
________________________________________
http://myitforum.com/cs2/blogs/jsandys/default.aspx

(in reply to swood)
Post #: 2
RE: Having problems scripting Netdom to rename systems - 8/20/2008 12:12:43 PM   
swood

 

Posts: 473
Score: 5
Joined: 12/6/2001
Status: offline
Acually I'm running it in a batch file from a UNC path. I found that if I ran this from the actual user machine, at the cmd prompt it ran successfully

for /f %a IN ('type currentname.txt') DO netdom RenameComputer 
%computername%  /NewName:%a /UserD:domain\admin /passwordD:password

I may have to change things so the script will run on the client instead of from our network.

_____________________________

Sandy Wood
Network Admin
Orange County District Attorney

(in reply to jsandys)
Post #: 3
RE: Having problems scripting Netdom to rename systems - 8/26/2008 12:31:32 PM   
ndaniels


Posts: 181
Score: 31
Joined: 2/24/2006
From: The Republic of Elbonia
Status: offline
My guess is that the reason it is failing when you run it from the UNC path is that the batch file is defaulting to the Windows directory and the text file you are attempting to process does not reside there.  If you specify the UNC path to your text file, it would most likely work...

for /f %a IN ('type "\\server\share\folder\currentname.txt"') DO ...

This may also be of assistance...
http://www.myitforum.com/forums/%25%7Edp0_variable/m_178011/tm.htm#178062

(in reply to swood)
Post #: 4
Page:   [1]
All Forums >> [Scripting Technologies] >> General Scripting >> Having problems scripting Netdom to rename systems Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts



  
Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

0.672