How to set env. var from C program (Developers)
> > Hm, that I feared about - you mean there's no standard C function to do
> > this. As I try to keep portability over dos/win/linux I don't want
> > implement any dirty hack like direct rewriting memory.
>
> Without a "dirty hack" you wont be able to do it. But if you don't fear
> "undocumented features" then it can be done!
>
> > Hm, it seems I have to use such batch files because it seems that I
> cannon feed SET with redirector <
> > SET VAR=<program.exe
> > doesn't work, it has to be file. And under dos I can use only real file
> on disk...
>
> That's true and that's exactly why the utility PIPESET exists. Get the
> DOSUTILS package e.g. from here:
> http://www.bttr-software.de/products/jhoffmann/ and see
> whether it does what you need. You could do it with such a command line:
>
> program.exe | PIPESET VAR
>
> Or look into the sources, which are also included in the package, to see
> how it can be done in C.
PIPESET let me remember Horst Schaeffer's batch support tools.
http://www.horstmuc.de/horst.htm
The NSET document even has a section for workarounding in NTDVM environment:
------------------------------------------------------------------------
NSET Work-around for WIN NT/2000/XP NSET Ver 2.1
------------------------------------------------------------------------
NSET writes variable assignments directly into the environment variable
space of COMMAND.COM. However, this does no work under Win NT/2000/XP.
Work-around:
NSET also supports sending the string to STDOUT, instead assigning it
to a variable. This is done by omitting the variable name (not the "="
sign).
Example: CD | nset currDir=$0 (normal mode, sets variable)
CD | nset =$0 (string is output to screen)
Now, you prepend "SET varname=" to the string, and send the result to
a temporary batch file (which is CALLed to execute the SET statement).
Example: CD | nset =SET currdir=$0 > temp.bat
call temp.bat
Actually, compared to normal mode, you just insert "=SET", and redirect
the output. Everything else remains the same.
Example: CD | nset currDir=$0 (normal mode)
CD | nset =SET currdir=$0 > temp.bat
---- ----------
Remember to delete the temporary batch file after use.
** 20.05.1999
Complete thread:
- How to set env. var from C program - RayeR, 15.01.2013, 04:34 (Developers)
![Open in board view [Board]](img/board_d.gif)
![Open in mix view [Mix]](img/mix_d.gif)
- How to set env. var from C program - Laaca, 15.01.2013, 07:41
- How to set env. var from C program - RayeR, 15.01.2013, 10:31
- How to set env. var from C program - tom, 15.01.2013, 13:54
- How to set env. var from C program - RayeR, 15.01.2013, 14:07
- How to set env. var from C program - tom, 15.01.2013, 15:41
- How to set env. var from C program - marcov, 16.01.2013, 15:19
- How to set env. var from C program - RayeR, 16.01.2013, 23:33
- How to set env. var from C program - RayeR, 15.01.2013, 16:24
- How to set env. var from C program - bocke, 18.01.2013, 16:57
- How to set env. var from C program - RayeR, 15.01.2013, 14:07
- How to set env. var from C program - bretjohn, 15.01.2013, 17:30
- How to set env. var from C program - RayeR, 15.01.2013, 23:51
- How to set env. var from C program - bretjohn, 16.01.2013, 01:05
- How to set env. var from C program - RayeR, 16.01.2013, 03:20
- How to set env. var from C program - bretjohn, 16.01.2013, 17:08
- How to set env. var from C program - RayeR, 16.01.2013, 03:20
- How to set env. var from C program - bretjohn, 16.01.2013, 01:05
- How to set env. var from C program - RayeR, 15.01.2013, 23:51
- How to set env. var from C program - j_hoff, 15.01.2013, 23:57
- How to set env. var from C program - RayeR, 16.01.2013, 00:49
- How to set env. var from C program - roytam, 16.01.2013, 04:57
- How to set env. var from C program - roytam, 16.01.2013, 05:13
- How to set env. var from C program - j_hoff, 16.01.2013, 08:11
- How to set env. var from C program - RayeR, 16.01.2013, 00:49
- How to set env. var from C program - tom, 15.01.2013, 13:54
- How to set env. var from C program - RayeR, 15.01.2013, 10:31
- How to set env. var from C program - georgpotthast, 15.01.2013, 22:20
- How to set env. var from C program - RayeR, 15.01.2013, 23:48
- How to set env. var from C program - Laaca, 15.01.2013, 07:41
Mix view