Solved

How do I add text file input to this bach file

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

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 68

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Scenario:  You do full backups to a internal hard drive in either product (SBS or Server 2008).  All goes well for a very long time.  One day, backups begin to fail with a message that the disk is full.  Your disk contains many, many more backups th…
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…
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now