Topic: Setting a DOS environment variable. (1 of 10), Read 49 times
Conf: Other, General, etc.
From: Peter Rejto
Date: Wednesday, May 30, 2007 08:43 PM

Hello,

I have a hunch that I have a DOS issue, but I thought there is no harm done asking it.

Here are the specifics:
1.
I can shell out to DOS with the usual, {Misc, DOS shell}
menu commands. Then I can type "SET ATOK=0" and this works like a charm!
2.
Now I would like to automate this and would like to use a Vedit macro and this is where I do have the problem.

I tried the

system("SET ATOK=0", DOS+MAX)

macro and this did not work.


Thanks,

-peter.

 


Topic: Setting a DOS environment variable. (2 of 10), Read 48 times
Conf: Other, General, etc.
From: Ian Binnie
Date: Thursday, May 31, 2007 01:43 AM

On 5/30/2007 8:43:52 PM, Peter Rejto wrote:
>Hello,
>
>I have a hunch that I have a
>DOS issue, but I thought there
>is no harm done asking it.
>
>Here are the specifics:
>1.
>I can shell out to DOS with
>the usual, {Misc, DOS shell}
>menu commands. Then I can type
>"SET ATOK=0" and this works
>like a charm!
>2.
>Now I would like to automate
>this and would like to use a
>Vedit macro and this is where
>I do have the problem.
>
>I tried the
>
>system("SET ATOK=0", DOS+MAX)
>
>macro and this did not work.
>

Peter,

Under 2K/XP (and probably 98) the shell starts a new process, which inherits environment variables.

Any new environment variables are local to this process, and cease to exist when it finishes.

There is no way to modify the calling process environment (except using protected kernel API).

A process can modify its own environment (using a putenv API), and this would then be inherited by child processes.

In short, Vedit would need to call the putenv API, or provide a spawn which set the environment.

 


Topic: Setting a DOS environment variable. (3 of 10), Read 48 times
Conf: Other, General, etc.
From: Peter Rejto
Date: Thursday, May 31, 2007 09:04 AM

On 5/31/2007 1:43:20 AM, Ian Binnie wrote:
>On 5/30/2007 8:43:52 PM, Peter Rejto
>wrote:
>>Hello,
>>
>>I have a hunch that I have a
>>DOS issue, but I thought there
>>is no harm done asking it.
>>
>>Here are the specifics:
>>1.
>>I can shell out to DOS with
>>the usual, {Misc, DOS shell}
>>menu commands. Then I can type
>>"SET ATOK=0" and this works
>>like a charm!
>>2.
>>Now I would like to automate
>>this and would like to use a
>>Vedit macro and this is where
>>I do have the problem.
>>
>>I tried the
>>
>>system("SET ATOK=0", DOS+MAX)
>>
>>macro and this did not work.
>>
>
>Peter,
>
>Under 2K/XP (and probably 98) the shell
>starts a new process, which inherits
>environment variables.
>
>Any new environment variables are local
>to this process, and cease to exist when
>it finishes.
>
>There is no way to modify the calling
>process environment (except using
>protected kernel API).
>
>A process can modify its own environment
>(using a putenv API), and this would
>then be inherited by child processes.
>
>In short, Vedit would need to call the
>putenv API, or provide a spawn which set
>the environment.
>
>
>

Thanks Ian,


>Any new environment variables are local
>to this process, and cease to exist when
>it finishes.

I need only a local new environment variable.


Let me backtrack and give you the motivation:
I would like to use a Vedit macro to
automate the task of dialing a phone number. A
task that I can do in Vedit using the menu
commands.

Oops, I just realized, I should use the Vedit
{Misc, Record quick macro} menu command.


Thanks again for your reply, and I shall report
back to you.

-peter.

 


Topic: Re: Setting a DOS environment variable. (4 of 10), Read 47 times
Conf: Other, General, etc.
From: Ted Green
Date: Thursday, May 31, 2007 10:24 AM

At 01:43 AM 5/31/2007, you wrote:
>In short, Vedit would need to call the putenv API, or provide a spawn which set the environment.

In words, there is no easy way (or any way that I can think of) that VEDIT can change a global environment variable.

Ted.

 


Topic: Setting a DOS environment variable. (5 of 10), Read 46 times
Conf: Other, General, etc.
From: Peter Rejto
Date: Thursday, May 31, 2007 01:48 PM

On 5/31/2007 1:43:20 AM, Ian Binnie wrote:

Thanks again, Ian:

>Any new environment variables are local
>to this process, and cease to exist when
>it finishes.
>
All that I need is to set a new local environment v variable. I take that this is pretty standard for you.

Well, it certainly was not standard for me. I did a little bit more thinking and this is what I came up with:

I put the SET ATKO=0 command into a batch file. Then I use the CALL subcommand to call another batch file which does the actual task. I called this batch file JOINT.BAT. Finally, I use the Vedit System( ) command to invoke this
JOINT.BAT file. It seems to work fine for me.

In the process I have learned something interesting. Specifically, I have learned a work around for adding two DOS commands as parameters for the Vedit System( ) command.

Now I realize, I have asked the wrong question.
I should have asked: Can I add two DOS commands
as parameters to the Vedit System( ) command.
If not, is there a workaround for it?


Thanks again,


-peter.

 


Topic: Setting a DOS environment variable. (6 of 10), Read 50 times
Conf: Other, General, etc.
From: Ian Binnie
Date: Thursday, May 31, 2007 10:34 PM

On 5/31/2007 1:48:53 PM, Peter Rejto wrote:
>On 5/31/2007 1:43:20 AM, Ian Binnie
>wrote:
>
>Thanks again, Ian:
>
>>Any new environment variables are local
>>to this process, and cease to exist when
>>it finishes.
>>
>All that I need is to set a new local
>environment v variable. I take that this
>is pretty standard for you.
>
>Well, it certainly was not standard for
>me. I did a little bit more thinking and
>this is what I came up with:
>
>I put the SET ATKO=0 command into a
>batch file. Then I use the CALL
>subcommand to call another batch file
>which does the actual task. I called
>this batch file JOINT.BAT. Finally, I
>use the Vedit System( ) command to
>invoke this
>JOINT.BAT file. It seems to work fine
>for me.

Peter,

I have from time to time used Vedit to construct batch files.

It is not necessary to call one batch from another.
Provided you put all your commands in the one file it should be OK.

>In the process I have learned something
>interesting. Specifically, I have
>learned a work around for adding two DOS
>commands as parameters for the Vedit
>System( ) command.
>
>Now I realize, I have asked the wrong
>question.
>I should have asked: Can I add two DOS
>commands
>as parameters to the Vedit System( )
>command.
>If not, is there a workaround for it?

Windows 2K, XP does allow multiple commands, if separated by "&&".
I doubt this would work from Vedit, as it is calling a 16bit process.

In practice these are hard to debug, and it is much easier to just construct a batch file.

Vedit seems to call these via one of the pif files in the vedit directory. I am unsure of the mechanism.

It may be possible to set environment variables by creating autoexec.nt with SET commands in the root of your system drive.

 


Topic: Setting a DOS environment variable. (7 of 10), Read 57 times
Conf: Other, General, etc.
From: Peter Rejto
Date: Friday, June 01, 2007 01:31 AM

On 5/31/2007 10:34:51 PM, Ian Binnie wrote:

Thanks Ian,

You gave me quite a few things to study.

So, at present I shall concentrate on:

>Windows 2K, XP does allow multiple
>commands, if separated by "&&".
>I doubt this would work from Vedit, as
>it is calling a 16bit process.
>
>In practice these are hard to debug, and
>it is much easier to just construct a
>batch file.
>
In the meantime, I have been studying the CMD.EXE command switches, in particular the && switch. You are right that I could not use it in Vedit. When I tried to connect two commands in the argument of the Vedit System( ) function, I ended up with an error message.

In studying these switches Vedit was really helpful. Specifically, I used the Vedit macro,

system("cmd /?", MAX).

This macro opened up a Maximal DOS window and typed out a few pages of information. So, a big thank you to Ted for this big window !

Of course, I would have much preferred to pipe this information to a file. So, I also experimented with the macro,

system("cmd /? > com.txt", MAX)


However, this macro ignored the piping part of the command.

So, I tried to use the same command from the Windows 2000,

{start, run } menu. I got the same result. That is to say the piping part was ignored. Of course, I could not tell Windows 2000 to maximize the window.


My system seems to be stable and I just do not know why the piping part of the command was ignored. I would really appreciate your repeating this simple experiment for me.

Looking forward to hearing from you.

-peter.

 


Topic: Setting a DOS environment variable. (8 of 10), Read 69 times
Conf: Other, General, etc.
From: Ian Binnie
Date: Friday, June 01, 2007 02:55 AM

On 6/1/2007 1:31:51 AM, Peter Rejto wrote:
>On 5/31/2007 10:34:51 PM, Ian Binnie
>wrote:
>
>In the meantime, I have been studying
>the CMD.EXE command switches, in
>particular the && switch. You are right
>that I could not use it in Vedit. When I
>tried to connect two commands in the
>argument of the Vedit System( )
>function, I ended up with an error
>message.
>
>In studying these switches Vedit was
>really helpful. Specifically, I used the
>Vedit macro,
>
>system("cmd /?", MAX).
>
>This macro opened up a Maximal DOS
>window and typed out a few pages of
>information. So, a big thank you to Ted
>for this big window !
>
>Of course, I would have much preferred
>to pipe this information to a file. So,
>I also experimented with the macro,
>
>system("cmd /? > com.txt", MAX)
>
>
>However, this macro ignored the piping
>part of the command.
>
>So, I tried to use the same command from
>the Windows 2000,
>
>{start, run } menu. I got the same
>result. That is to say the piping part
>was ignored. Of course, I could not tell
>Windows 2000 to maximize the window.

Peter,
For some reason I do not understand commands from the Run menu do not always allow redirection.

Why not just run Programs/Accessories/Command Prompt from the start menu. This will allow redirection.

If you really want to do it from the Run menu try:-
%comspec% /c cmd /? >d:\cmd.txt

You can get 2K to maximise.
Then the command window opens, right click on the title bar, select Properties/Layout/Window Size and change this (or any other attributes e.g. colours).

You can even save this to be used for future windows of the same name.

 


Topic: Setting a DOS environment variable. (9 of 10), Read 69 times
Conf: Other, General, etc.
From: Peter Rejto
Date: Friday, June 01, 2007 07:35 AM

On 6/1/2007 2:55:08 AM, Ian Binnie wrote:
>For some reason I do not understand
>commands from the Run menu do not always
>allow redirection.
>
>Why not just run
>Programs/Accessories/Command Prompt from
>the start menu. This will allow
>redirection.
>
>If you really want to do it from the Run
>menu try:-
>%comspec% /c cmd /? >d:\cmd.txt
>
Ian,

Both of your suggestions work like a charm.

I like your second suggestion very much. In fact I just copied and pasted it from this email to my "run" window
and got the cmd help file, cmd.txt.

My slight change was to replace your /c parameter by the parameter /k. This way the DOS window stayed open and I could type in a dir cmd.txt command, to verify the result.

At the same time, I copied your command to my Win2K template file so I can copy and paste it again.

I have a hunch that your suggestion also could be used to explain the meaning of the CAN NOT SHELL OUT, ERROR 2 message, that I got from Vedit. If I understand it correctly the problem is to transmit the "/?" parameter to the CMD.EXE command. I take that Vedit was unsuccessful in finding CMD.EXE and that is why it sent that error message.

So, I shall try to adapt your suggestion to Vedit as well.
My personal preference is to do as much work in Vedit as possible.


Thanks again,

-peter.

 


Topic: Re: Setting a DOS environment variable. (10 of 10), Read 39 times
Conf: Other, General, etc.
From: Christian Ziemski
Date: Tuesday, June 05, 2007 04:06 PM

On Fri, 01 Jun 2007 01:31:00 -0400, Peter Rejto wrote:

>So, I also experimented with the macro,
>
>system("cmd /? > com.txt", MAX)
>
>However, this macro ignored the piping part of the command.

Peter:

Here it works.

Perhaps your file 'com.txt' was created in another directory than you
expected? Have you tried it with complete path?
For example: system("cmd /? > C:\com.txt", DOS)

You should use the DOS option with these DOS commands.
It often helps to avoid the "CAN NOT SHELL OUT" error.
The help for System() has detailed infos about these options.


Christian