Jump to content

Recommended Posts

Posted

Goodmorning. I am having trouble assining the result of a funtion to a variable in a batch file. I am using compname.exe to generate a computername(compname.exe /d ?s) I want to assign this to a variable so it can be used with sysprep and the UserData section. Here is what I have

Set strComputername = compname.exe /d ?s

echo Computername ="%strComputername%" > sysprep2.inf

Later the sysprep2.inf will be combined using the copy command, but I need this problem resolved. Thanks in advance for any help you provide it is greatly appreciated.


Posted

You can use ...

set "cmd=compname /d ?s"

for /f "Tokens=1*" %%a in ('%CMD%') do set strComputername=%%a

echo Computername ="%strComputername%" > sysprep2.inf

HTH

Posted

That worked like a champ ... Do you have a guide or book you can direct me to so I can understand exactly what you are doing ? I appreciate your help...

Thanks,

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...