in reply to Getting the ENV from the .bat file

You will need to adapt Get default login environment to your situation. Likely this involves using cmd /c your-batch-file.bat && set to output the environment.

Replies are listed 'Best First'.
Re^2: Getting the ENV from the .bat file
by sowndarr (Initiate) on Feb 18, 2009 at 14:29 UTC
    Sorry, I am not understanding. If I am having the bat file my_env.bat which have the value "set MY_HOME=C:\sowndar set VAR1=12". Does the perl will call some this like this, cmd /c "my_env.bat"; print $ENV{MY_HOME}."\n". $ENV{VAR1}; # Will this give proper value

      What you wrote has no semblance to the code in the nodes I linked. Please read Get default login environment.

      As to your code, did you try it? If so, what were the results?

        I tried with the following code, $res = get_login_env(); print $res; sub get_login_env { local %ENV; my $env = `echo env | perl -e 'exec {"C:\\temp\\test.bat"} -sh'`; print $env; if (wantarray) { my @pieces = ($env =~ m/^(.*?)=((?:^\n\\|\\.|\\\n)*)/gm ); s/\\(.)/$1/g foreach @pieces; return @pieces; } else { return $env; } } Where the test.bat file is having the set commands. It is not throwing error and it is not getting the varible also.