Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

SET enviroment variables

  • 03-11-2004 11:12am
    #1
    Moderators, Society & Culture Moderators Posts: 9,689 Mod ✭✭✭✭


    I'm trying to set enviroment variables and use them as directory names in a batch file. For some reason they don't seem to set correctly, or maybe I'm just not reading the values back correctly. I'm using windows 2000 with administrator rights. As an example if I use a CMD prompt to enter

    "SET folname = test"

    and then type

    "SET folname"

    I get

    "folname = test"

    which is correct but if I then

    "ECHO %folname%"

    I just get

    "%folname%"

    and if I try to use %folname% in a batch file it just seems to expand to blank as if it wasn't defined (even though I SET it earlier in the batch file).

    I'm sure I'm missing something obvious, anybody know what it is ?


Comments

  • Registered Users, Registered Users 2 Posts: 37,485 ✭✭✭✭Khannie


    It's the spaces.....

    set folname=test
    echo %folname%
    prints:
    test

    Enjoy :)


  • Moderators, Society & Culture Moderators Posts: 9,689 Mod ✭✭✭✭stevenmu


    That did it thanks, I knew I was missing something simple.

    In case anyone's interested I was just doing a batchfile to create a directory named for the current date, commands are below.


    @echo off
    set d=%date:~4,2%
    set m=%date:~7,2%
    set y=%date:~10%
    set dmy=%d%%m%%y%
    mkdir %dmy%


  • Registered Users, Registered Users 2 Posts: 2,694 ✭✭✭Dingatron


    Thanks for printing that. Could come in very handy. On this note does anyone know of any decent web sites for teaching this stuff? I would like to be able to learn how to script with a slant towards unix scripting.


  • Registered Users, Registered Users 2 Posts: 834 ✭✭✭fragile


    Google is your friend..

    DOC Batch Programming

    For a list of new commands that have been added in 2000/XP just look at the Windows Help under Reference

    Linux shell scripting tutorial

    Advanced Bash-scripting guide


  • Registered Users, Registered Users 2 Posts: 2,694 ✭✭✭Dingatron


    Thanks Fragile. I could have googled I supose but I knew that in asking it would narrow down the search too only the decent sites. I'll have a look at your links and karma to you. :-)


  • Advertisement
Advertisement