Tech Off Thread

12 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Does cmd.exe support rc files?

Back to Forum: Tech Off
  • User profile image
    TimP

    Is there a cmd.exe equivalent for something like .bashrc? I want to set and change a few environment variables every time I start a shell. I can't make permanent changes to the environment variables due to the way the computer is setup.

    The only way I can think of doing it is pretty ugly. A batch file like this:

    set MYVAR=abc
    cmd

    The problem is I'd have to invoke the shell with this batch file every time.

  • User profile image
    Sven Groot

    Why can't you use the per-user environment variable settings?

  • User profile image
    aspnix
  • User profile image
    Matthew van Eerde

    HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun

    C:\>cmd /?
    ...
    If /D was NOT specified on the command line, then when CMD.EXE starts, it
    looks for the following REG_SZ/REG_EXPAND_SZ registry variables, and if
    either or both are present, they are executed first.

        HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun

            and/or

        HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun

  • User profile image
    Matthew van Eerde

    For tons of fun, set that key to "exit" (w/o quotes) >Smiley

    Or better yet:

    C:\>type cmd-enhancer.reg
    Windows Registry Editor Version 5.00

    [HKEY_CURRENT_USER\Software\Microsoft\Command Processor]
    "AutoRun"="echo (your message here) && pause && exit"

    mua ha ha...

  • User profile image
    TimP

    Sven Groot wrote:
    Why can't you use the per-user environment variable settings?


    It's a Netware based system, not AD, so everyone uses the same Windows user account with their respective home directory mounted after login.

  • User profile image
    Matthew van Eerde

    Given that, your batch-file solution sounds good.

  • User profile image
    littleguru

    Matthew van Eerde wrote:
    For tons of fun, set that key to "exit" (w/o quotes) >Smiley

    Or better yet:

    C:\>type cmd-enhancer.reg
    Windows Registry Editor Version 5.00

    [HKEY_CURRENT_USER\Software\Microsoft\Command Processor]
    "AutoRun"="echo (your message here) && pause && exit"

    mua ha ha...


    Muahahaha! Big Smile Sweet.

  • User profile image
    SoreGums

    TimP wrote:
    Is there a cmd.exe equivalent for something like .bashrc? I want to set and change a few environment variables every time I start a shell. I can't make permanent changes to the environment variables due to the way the computer is setup.

    The only way I can think of doing it is pretty ugly. A batch file like this:

    set MYVAR=abc
    cmd

    The problem is I'd have to invoke the shell with this batch file every time.

    If there is only one to set you could use the /k switch...

    but cmd /? should help you out Smiley

  • User profile image
    TimP

    I'll see if /k makes it any easier, if not I'll just go with the batch file. The situation is that all the lab computers have Cygwin installed, but C:\cygwin\bin is not in the path so if I want to use any Cygwin utilities I have to add it to the path on every shell window I open. I wonder if I can make some sort of Netware post-login script to set it for the session. I know admins can make Netware scripts, but I'm not sure if users can add their own.

  • User profile image
    saporis

    Would system environment variables work for you?  I run cygwin/X11 with XP and have no problem with the cygin/bin.

    You can access a "visual" example via a right click of "My Computer/Properties/Advanced Tab/Environment Variables/System variables".  I know there's a registry key somewhere you can forcibly set (for all users, instead of local users), but it escapes me at the moment...

    Also, it's possible to tweak this in the Group Policy editor ("gpedit.msc").  Set a startup script?

    There's possibly loads of solutions to this...   

  • User profile image
    TimP

    I would have to be able to do this from a regular non-admin user account since this is not my box.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.