?
Solved

How do I add text file input to this bach file

Posted on 2014-10-24
4
Medium Priority
?
196 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
[X]
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
  • 2
  • 2
4 Comments
 
LVL 70

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 70

Accepted Solution

by:
Qlemo earned 2000 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

What Is Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.

Question has a verified solution.

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

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 article explains how to install and use the NTBackup utility that comes with Windows Server.
This tutorial will give a an overview on how to deploy remote agents in Backup Exec 2012 to new servers. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as connecting to a remote Back…
This tutorial will give a short introduction and overview of Backup Exec 2012 and how to navigate and perform basic functions. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as conne…
Suggested Courses

801 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