Basically, the code in Get default login environment respectively its replies should allow you to read all the environment variables a shell script sets.

You will need to learn about how your shell (cmd.exe) invokes batch files and how you can run your own code in the context of such a batch file, but it's not hard. The following code works for me to retrieve the environment for a batch file under Windows:

my $batchfile= 'C:\\test.cmd'; my $cmd= qq("$batchfile" && set); print "Environment: $_" for `$cmd`;

... where test.cmd contains

set TEST=C:\test.pl

You should easily be able to combine this part with the parsing parts of Get default login environment into something that retrieves the environment under Windows.


In reply to Re: Best ways to run a windows batch with Perl by Corion
in thread Best ways to run a windows batch with Perl by luxAeterna

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.