Solved

How do I add text file input to this bach file

Posted on 2014-10-24
4
190 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SYSVOL corrupted 12 151
Confirming a network firewall is blocking connections to a port 7 68
Migrating VM's from one 2008 R2 host to another 2 24
how to diff two files 12 37
I was supporting a handful of Windows 2008 (non-R2) 2 node clusters with shared quorum disks. Some had SQL 2008 installed and some were just a vendor application that we supported. For the purposes of this article it doesn’t really matter which so w…
A safe way to clean winsxs folder from your windows server 2008 R2 editions
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 configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…

680 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