Home

Results 1 to 4 of 4

Thread: Run Script - variable confusion

Threaded View

  1. #1
    Join Date
    Feb 2008
    Posts
    359

    Run Script - variable confusion

    I don't quite understand the scripting's interpretation of variables.

    I have this snippet of batch commands which works as intended from a DOS prompt:

    Code:
    cd /d "%TEMP%"
    type %~F0 > %TEMP%\ZCMBundle.cmd
    set >> C:\ENH\LOGS\ZenInfo.log
    echo %DATE% %TIME% ZAC ZenInfo Bundle > C:\ENH\LOGS\ZenInfo.log
    for /f "tokens=*" %%A in ('dir zeninfo*.zip /aa /b') do set ZENINFOZIP=%%A
    echo ZENINFOZIP=[%ZENINFOZIP%] >> C:\ENH\LOGS\ZenInfo.log
    However, to get this to work the same way/properly in a Script content of a bundle, I have to use extra %s:
    Code:
    cd /d "%%TEMP%%"
    type %~F0 > %TEMP%\ZCMBundle.cmd
    set>> C:\ENH\LOGS\ZenInfo.log
    echo %DATE% %TIME% ZAC ZenInfo Bundle > C:\ENH\LOGS\ZenInfo.log
    for /f "tokens=*" %%%A in ('dir zeninfo*.zip /aa /b') do set ZENINFOZIP=%%%A
    echo ZENINFOZIP=[%ZENINFOZIP%] >> C:\ENH\LOGS\ZenInfo.log
    If I use the first code block as the script in the bundle, the %TEMP% resolves to C:\WINDOWS\TEMP yet the %TEMP% on the second line correctly resolves to C:\user\bkeadle\appdata\local\temp (which is what TEMP is set to when I just output SET to the log) . I have to use the second code block with the extra %s to result in a script that actually looks like the first code block and to get the bundle to work as intended.

    I don't get it.
    Last edited by bkeadle; 13-May-2015 at 05:57 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •