1

I have a simple vb script (file name: wiguid.vbs) that generates a new Guid.

set obj = CreateObject("Scriptlet.TypeLib")  
WScript.Echo obj.GUID

I need to call this script from a cmd batch file, store new guid in a command parameter, and pass that variable to other vb scripts. But I fail to store value generated in a vbscript to a command parameter.

Something like:

cscript wiguid.vbs 
set NewGuid = '??Should get value from above script call'
cscript OtherVbScript.vbs "SET Value='%NewGuid%'"

I tried different search combinations but couldn't get any way to achieve that.

Any pointers/suggestions would be of help! thanks.

1 Answer 1

3
@echo off
    setlocal enableextensions

    for /f %%a in ('cscript //nologo wiguid.vbs') do set "newGUID=%%a"
    echo new guid = %newGUID%

    endlocal

Without using a temporary file, for /f is the usual way of assigning a value to a variable from the output of the execution of a command.

It just runs the indicated command and for each of the lines in the output, the code in the do clause is executed. The replaceable parameter (the %%a) of the for command will hold all or part of the line. See for /? for a complete reference

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.