How to set OS environment variable value? 
Author Message
 How to set OS environment variable value?

Hello

I am trying to set a Windows O.S. environment variable by:
RUN SET B=1

But GETENV('B') does not return any value. I have also written above code in
a batch file. Running this batch file does not seem to set environment
variable. How can I set an O.S environment variable through VFP?

Platform:VFP 6.0 on Windows 97

Thanks
--

Kamran Ahmad



Tue, 13 Nov 2001 03:00:00 GMT  
 How to set OS environment variable value?
Kamran,
The problem is that a RUN or Batch file create the environmental variable
only in the current (temporary) environment - not in the one VFP is running.
While I believe there aere some API calls that would allow you to create a
variable (and possibly extend the environment space if there was sufficient
room left), these are not trivial. You may want to consider writing to the
Registry (the new way) or to an .INI file (the old way), if you are simply
trying to share information with some other process(es).

Rick


Quote:

> Hello

> I am trying to set a Windows O.S. environment variable by:
> RUN SET B=1

> But GETENV('B') does not return any value. I have also written above code
in
> a batch file. Running this batch file does not seem to set environment
> variable. How can I set an O.S environment variable through VFP?

> Platform:VFP 6.0 on Windows 97

> Thanks
> --

> Kamran Ahmad



Tue, 13 Nov 2001 03:00:00 GMT  
 How to set OS environment variable value?
This does set the variable, but only in the current DOS session.  As soon as
the run finished the DOS session any created variables dissappear along with
DOS environement.  I recall some undocumented DOS calls to set the "master"
environement, but this is a few years ago!  There may be a way in windows
(using the api).

If you let the group know the general problem, there may be another
solution.

John.


Quote:

> Hello

> I am trying to set a Windows O.S. environment variable by:
> RUN SET B=1

> But GETENV('B') does not return any value. I have also written above code
in
> a batch file. Running this batch file does not seem to set environment
> variable. How can I set an O.S environment variable through VFP?

> Platform:VFP 6.0 on Windows 97

> Thanks
> --

> Kamran Ahmad



Tue, 13 Nov 2001 03:00:00 GMT  
 How to set OS environment variable value?
Buenos, amigo!


Then create a file c:\batch\mysets.bat:
set b=1

Restart the Windows. Then in VFP
? GETENV("B")

Hasta la vista!

Roman  I Nickolaychuk,
Soft Ltd.,  Ashkhabad Turkmenistan.

Quote:

>Hello

>I am trying to set a Windows O.S. environment variable by:
>RUN SET B=1

>But GETENV('B') does not return any value. I have also written above code
in
>a batch file. Running this batch file does not seem to set environment
>variable. How can I set an O.S environment variable through VFP?

>Platform:VFP 6.0 on Windows 97



Wed, 14 Nov 2001 03:00:00 GMT  
 How to set OS environment variable value?

Quote:
>If you let the group know the general problem, there may be another
>solution.

>John.

Well the general problem is that I do not want my users to execute my
application more than once on the same PC. Although the application is
written for multi-user environment and running more than one copies is not
big trouble. But my user sometimes opens several copies of the application,
by clicking its icon many times.

By setting environment variable some value and checking at startup of
application might be one solution.

Regards

Kamran Ahmad



Thu, 15 Nov 2001 03:00:00 GMT  
 How to set OS environment variable value?
I belive there's another active thread on one of the fp newgroups, it seems
like a mutex is the way to do it, although there are many other ways,
including temp files and using the api to find the other's window.

John.


Quote:


> >If you let the group know the general problem, there may be another
> >solution.

> >John.

> Well the general problem is that I do not want my users to execute my
> application more than once on the same PC. Although the application is
> written for multi-user environment and running more than one copies is not
> big trouble. But my user sometimes opens several copies of the
application,
> by clicking its icon many times.

> By setting environment variable some value and checking at startup of
> application might be one solution.

> Regards

> Kamran Ahmad



Thu, 15 Nov 2001 03:00:00 GMT  
 How to set OS environment variable value?
There are also uploads on the www.universalthread.com for doing this.
Perhaps something there will help you.  You have to be a member, but basic
membership is free.

--
x-no-archive: yes

Nancy

Quote:
> Well the general problem is that I do not want my users to execute my
> application more than once on the same PC.



Fri, 16 Nov 2001 03:00:00 GMT  
 How to set OS environment variable value?
Someone here suggested using the DDE connections
to do that. When the first instance of foxpro opened the
connection, all subsequent attempts to open the same
connection will fail, since it is in use.

Quote:
>I belive there's another active thread on one of the fp
newgroups, it seems
>like a mutex is the way to do it, although there are many other
ways,
>including temp files and using the api to find the other's

window.


Sat, 17 Nov 2001 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. ? Setting Operating System Environment Variables ??

2. Setting Global Environment-Variables for Exes in VFP 5.a SP3

3. Set an environment value

4. Set an environment value...

5. Set A Value to a Variable

6. Return values from the OS() command.

7. NT value for OS()

8. FoxPro and DOS environment variables...

9. Config.fpw and environment variables

10. cannot locate COMSPEC environment variable

11. HELP: Environment variables in CA-Clipper

12. How VFP to get DOS/System environment variables?

 

 
Powered by phpBB® Forum Software