Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How do I add text file input to this bach file

Posted on 2014-10-24
4
189 Views
Last Modified: 2014-10-24
I have the following batch file to pull a computer's UUID and add it to the WIndow's Deployment Service for Prestaging.  

I have gone into my existing AD and queried the Computer's from it and output it to a file called "ad.txt".  I want to use "ad.txt" as the input and run the below script:

for /f %%I IN (
'psexec  \\^%1 cmd /c "echo csproduct get UUID|wmic.exe" ^| ^
findstr /r ........-....-....-....-............ '
) do wdsutil /set-device /device:%1 /id:%%~I
0
Comment
Question by:mrfite
  • 2
  • 2
4 Comments
 
LVL 69

Expert Comment

by:Qlemo
ID: 40402385
for /F "tokens=*" %%F in (ad.txt) do call wdsadd %%F
exit /b

:wdsadd
for /f %%I IN (
'psexec  \\^%1 cmd /c "echo csproduct get UUID|wmic.exe" ^| ^
findstr /r ........-....-....-....-............ '
) do wdsutil /set-device /device:%1 /id:%%~I
exit /b

Open in new window

0
 

Author Comment

by:mrfite
ID: 40402396
Qlemo,

When I run the batch I get

'wdsadd' is not recognized as an internal or external command, operable program, or batch file.
0
 
LVL 69

Accepted Solution

by:
Qlemo earned 500 total points
ID: 40402399
Stupid me. Forgot an important colon.
for /F "tokens=*" %%F in (ad.txt) do call :wdsadd %%F
exit /b

:wdsadd
for /f %%I IN (
'psexec  \\^%1 cmd /c "echo csproduct get UUID|wmic.exe" ^| ^
findstr /r ........-....-....-....-............ '
) do wdsutil /set-device /device:%1 /id:%%~I
exit /b

Open in new window

0
 

Author Closing Comment

by:mrfite
ID: 40402412
Thanks for the quick response and solution that worked.
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A procedure for exporting installed hotfix details of remote computers using powershell
This article explains how to install and use the NTBackup utility that comes with Windows Server.
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

856 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