B4J Question Set operating system environment variable

Patent

Member
Licensed User
Longtime User
Hi guys,
is it possible to set a operating system environment variable with B4J i.e. on a Win System?

greets
 

DonManfred

Expert
Licensed User
Longtime User
I´m not sure if you can change the SYSTEMS Environment.
But i´m positive you can set the Environment to child-processes using the java ProcessBuilder.

Something like

B4X:
Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private jPB As jProcessbuilder
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
    MainForm.Show
 
    Dim cmds As List
    cmds.Initialize
    cmds.Add("D:\Notepad++\Notepad++.exe")
    cmds.Add("D:\Notepad++\shortcuts.xml")
 
    jPB.Initialize("PB")
    jPB.setEnvironmentVar("EnvVar","Value")
    jPB.start(cmds,"E:\")
End Sub
 

Attachments

  • jProcessBuilder.zip
    2.7 KB · Views: 154
Last edited:
Upvote 0

Patent

Member
Licensed User
Longtime User
thank you guys.my approach was to Start the app via a script and do the setting bevor the start of the VM.
it works but its not very ellegant so i will try processbuilder and/or jshell with 5.5b4j.
funny: erel is on time with my coding-problems !!!!! :)
thank you DonManfred, Rob, Erel
 
Upvote 0
Top