Powerbuilder Setting Environment variables in Windows 7

Posted on 2011-02-22
Last Modified: 2013-12-26

We define a local external function in a window below as

//Local External function
Function Boolean SetEnvironmentVariableA(String lpName, String lpValue) Library "kernel32.dll"

and then in a script call as
Boolean            lbl_ret       = TRUE
String             ls_envname
String            ls_version

ls_version      =      "1.0"
ls_env_name = "TESTENV"

lbl_ret = SetEnvironmentVariableA ( ls_envname, ls_version )

This works on XP, but not with Windows 7.
i.e The environment variable is created in XP, but  not in Windows 7.

Any help on how to create an environment variable from Powerbuilder in Windows 7 very much appreciated. ( Please note, for security reasosn, we are unable to use the RegistrySet function )

Running Powerbuilder 10.5.2 Build 7826

Question by:cintra
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 19

Accepted Solution

elimesika earned 150 total points
ID: 34957019
In windows 7 this function is in

Function Boolean SetEnvironmentVariableA(String lpName, String lpValue) Library "api-ms-win-core-processenvironment-l1-1-0.dll"

Open in new window


Assisted Solution

kmanoharnaik earned 100 total points
ID: 34958084

if it works in XP, not in WIndows 7, try adding alias name as below

alias for "SetEnvironmentVariableA;Ansi"

i am not sure if it works.

Please let me know if it works.


Author Comment

ID: 34959106
Thanks for both replies. Will check them both out and let you know the outcome, as well as awarding points.

Author Comment

ID: 34969760
The "SetEnvironmentVariableA;Ansi" did not work, though the use of the Ansi at the end was very useful info.


Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB.Net Reusable Form Layout 4 181
Doxygen plugin for Android Studio 1 682
Fast, free, private online code repository / editor 7 123
regex. How to include lines between 10 100
Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question