Guest Sandy Wood Posted August 19, 2008 Posted August 19, 2008 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 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 Why would it not pick up the value from the text file? -- Sandy Wood Orange County District Attorney
Guest Pegasus \(MVP\) Posted August 19, 2008 Posted August 19, 2008 Re: Problems trying to run netdom.exe from command prompt to rename sy "Sandy Wood" <sandy.wood@nospam.com> wrote in message news:1DADF6F0-F314-4BA1-8A00-58713E8C4507@microsoft.com... > 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 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 > > Why would it not pick up the value from the text file? > > -- > Sandy Wood > Orange County District Attorney Try this: for /f %a IN ('type currentname.txt') DO netdom RenameComputer OLDCOMPUTER /NewName:%a /UserD:domain\admin /passwordD:password Remember to put brackets around your enumeration statement! If your computer names come without any embedded spaces then you don't need the "delims= tokens=" stuff. If they do have spaces then "delims=" will suffice.
Guest Sandy Wood Posted August 19, 2008 Posted August 19, 2008 Re: Problems trying to run netdom.exe from command prompt to renam Re: Problems trying to run netdom.exe from command prompt to renam Thanks for the tip Pegasus. I ran your suggestion and it returned sucessfully. Thanks for the great tip! I was originally running it from a unc path in a batch file and that didn't seem to work...I can run it locally and it's fine! -- Sandy Wood Orange County District Attorney "Pegasus (MVP)" wrote: > > "Sandy Wood" <sandy.wood@nospam.com> wrote in message > news:1DADF6F0-F314-4BA1-8A00-58713E8C4507@microsoft.com... > > 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 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 > > > > Why would it not pick up the value from the text file? > > > > -- > > Sandy Wood > > Orange County District Attorney > > Try this: > for /f %a IN ('type currentname.txt') DO netdom RenameComputer > OLDCOMPUTER /NewName:%a /UserD:domain\admin /passwordD:password > > Remember to put brackets around your enumeration statement! > > If your computer names come without any embedded spaces then > you don't need the "delims= tokens=" stuff. If they do have spaces > then "delims=" will suffice. > > >
Guest Pegasus \(MVP\) Posted August 20, 2008 Posted August 20, 2008 Re: Problems trying to run netdom.exe from command prompt to renam Re: Problems trying to run netdom.exe from command prompt to renam Thanks for the feedback. "Sandy Wood" <sandy.wood@nospam.com> wrote in message news:4D47228F-A1AF-4ACD-B83A-904C0EFFBB29@microsoft.com... > Thanks for the tip Pegasus. I ran your suggestion and it returned > sucessfully. Thanks for the great tip! I was originally running it from a > unc > path in a batch file and that didn't seem to work...I can run it locally > and > it's fine! > > > -- > Sandy Wood > Orange County District Attorney > >
Recommended Posts