Make icon select environment at startup

timallen

timallen

Well Known Member
My client has two environments available to the users, PY7333 and PD7333. They want to avoid that they enter PY7333 thinking that it is PD7333, but users often start OneWorld and enter without looking at the environment.

Right now, I've fixed it by commenting out the [SIGNON] section in the JDE.INI and making the JDE.INI read only. This way, the user and environment boxes always come up blank. But this is a bit ugly.

The client wants to have two different icons to start OneWorld, one for PD and another for PY.

Is there some way of doing this? Or has anyone handled this problem in another way?

Thanks in advance.
 
Sounds like some lazy users to me, but here goes. Create two INI files reflecting the correct environment. Name them jde.py and jde.pd. Now, create a batch file that copies the appropriate INI file to the OS directory and then launches OEXPLORE.EXE. Problem solved. You could always tackle the monumental task of educating the users.... Naw, I guess that will never happen. That's why we have jobs, right?
 
Question, does all the user need to log into both the environment. IF not then you can remove the environemtn from their profile and they get to see only one environment from in theri log on. But I amsure this is not the case
 
Hi Tim

This is not a waterproof solution, but it may help users once they have logged in. In the task menus (whatever they are called or, in the case of the JDE Standard Task menu, Master Directory) just add - PRODUCTION - or -TEST- to the name of the first task your user encounters.

Rgds,
 
Thanks, I think this is what I'll end up doing.

You're absolutely right about this being a bit of a training issue. But I have to admit that there have been one or two times ;) when *I* have entered the wrong environment-- *usually* I notice the error. I hang my head in shaaame.

Fortunately, you are also right that this is why we have jobs!

__UPDATE__
here is the batch file I ended up using:

rem OW_PY.bat
@copy c:\winnt\jde.py c:\winnt\jde.ini
@oexplore

I have another one like it for production, where jde.py is replaced by jde.pd.

The jde.py/jde.pd files are copies of the original JDE.INI with the [SIGNON] section set like this:

;jde.py
[SIGNON]
LASTENV=PY7333
LASTUSER=

This causes the users to always get PY7333 from this icon, and they have to enter their user name (this could be set to always use the same last user).
 
Zoltan had a good post last year that could help with logging into the wrong environment. Do a search on the list for Color For Environments. Basically, you have a different background color for each environment. Unless you're color blind, it is pretty foolproof.
 
Great, I'll look it up.

Actually, I came up with a final VB Scripting version of this. It is the same as the batch file, except that it doesn't leave a command window hanging around on screen while OneWorld is running:

' __ OW_PY.vbs__
const taWindowHidden = 0
const taWindowShow = 1
const taWaitForFinish = True
const taDontWaitForFinish = False

Dim oSh
Set oSh = CreateObject("WScript.Shell")
oSh.run "cmd /c copy c:\winnt\jde.py c:\winnt\jde.ini", taWindowHidden, taWaitForFinish
oSh.run "C:\B7\system\Bin32\oexplore.exe", tsWindowShow, taDontWaitForFinish
set oSh = Nothing
 
Re: Make icon select environment at startup [DEFINITIVE]

Here is the definitive, all singing, all dancing version of the OneWorld startup script which allows you to specify the environment that the user will see when they start OneWorld. Note the commented portion which explains how to do this for a terminal server.

What this does, by the way, is to open the JDE.INI, search for the LASTENV entry, and overwrite it with the environment you want to log into. If the key doesn't exist (as in a new installation), it will create it. I used some code from Nolan Bagadiong which reads and writes to INI files from VBS programs.

//////////////////
' START FUNCTIONS AND SUBS HERE '===================
'
' VBScript Source File -- Created with SAPIEN Technologies PrimalSCRIPT(TM)
'
' NAME: VBScript ReadINI/WriteINI
'
' AUTHOR: Bagadiong, Nolan
' DATE : 7/27/2001
'
' COMMENT: Uses Regular Expressions to find keys and values; no longer case ' or space sensitive ' ' If you pass READINI(file, section, key), function returns scalar of the value ' assigned to key '

' If you pass READINI(file,"section", ""), function returns array of all keys ' under "section" ' ' If you pass READINI(file,"",""), function returns array of sections in the ' file '

'===================


'Usage
' READINI (file, section, item) returns value; otherwise returns ""

Function ReadINI(file, section, key)

set FileSysObj = CreateObject("Scripting.FileSystemObject")
ReadIni=""
If FileSysObj.FileExists(file) then
Set ini = FileSysObj.OpenTextFile( file, 1, False)

' Return array of sections if section and keys are empty
if section="" then
set reSection =new RegExp
reSection.Global =True
reSection.IgnoreCase=True
reSection.Pattern ="\[([a-zA-Z0-9 ]*)\]"

Do While ini.AtEndofStream =False
line = ini.ReadLine

if reSection.Test(line) then
tempSection=tempSection & reSection.Replace(line, "$1") & ","
end if
loop
ini.close
tempSection=left(tempSection, len(tempSection)-1)
ReadINI=split(tempSection,",")
set reSection=nothing
exit function
end if
' Return array of keys if keys are empty
if key="" then

set reSection =new RegExp
reSection.Global =True
reSection.IgnoreCase=True
reSection.Pattern ="\s*\[\s*" & section & "\s*\]"

Do While ini.AtEndofStream =False
line = ini.ReadLine

if reSection.Test(line) then
line=ini.ReadLine

do while instr(line,"[")=0
tempKeys=tempKeys & trim(left(line,instr(line,"=")-1)) & ","
line=ini.ReadLine
loop
tempKeys=left(tempKeys,(len(tempkeys)-1)) ' Remove last comma
ReadINI =split(tempKeys,",")
exit function
end if
loop
end if
'===================

' READINI Part for file, section, key

set reSection =new RegExp
reSection.Global =False
reSection.IgnoreCase=True
'reSection.Pattern ="\s*[\s*" & section & "\s*]"
reSection.Pattern ="\s*\[\s*" & section & "\s*\]"

set reKey =new RegExp
reKey.Global =False
reKey.IgnoreCase=True
reKey.Pattern="\s*" & key & "\s*=\s*"


Do While ini.AtEndofStream = False

line = ini.ReadLine

if reSection.Test(line) = True then

line=ini.ReadLine
do while instr(line,"[")=0

if reKey.Test(line) then

ReadINI=trim(mid(line,instr(line,"=")+1))

exit do
end if

line=ini.ReadLine
Loop

exit do
end if
loop
ini.Close
set reSection=nothing
set reKey =nothing
end if ' If FileSysObj
end function

'==================
' WRITEINI ( file, section, item, value )
' file = path and name of ini file
' section = [Section] must be in brackets in the ini file
' item = the variable to read;
' value = the value to assign to the item.
'
Sub WriteIni( file, section, item, value )
set FileSysObj = CreateObject("Scripting.FileSystemObject")
in_section = False
section_exists = False
item_exists = ( ReadIni( file, section, item ) <> "" )
wrote = False
path = Mid( file, 1, InStrRev( file, "\" ) )
Set read_ini = FileSysObj.OpenTextFile( file, 1, True, TristateFalse )
Set write_ini = FileSysObj.CreateTextFile( path & "temp_ini.ini", False )

set reWSection =new RegExp
reWSection.Global =False
reWSection.IgnoreCase=True
reWSection.Pattern ="\s*[\s*" & section & "\s*]"

set reItem =new RegExp
reItem.Global =False
reItem.IgnoreCase=True
reItem.Pattern ="\s*" & item & "\s*="

While read_ini.AtEndOfStream = False
line = read_ini.ReadLine

If wrote = False Then
If reWSection.Test(line) Then
section_exists = True
in_section = True
ElseIf InStr( line, "[" )> 0 Then
in_section = False
End If
End If

If in_section Then
If item_exists = False Then
write_ini.WriteLine line
write_ini.WriteLine item & "=" & value
wrote = True
in_section = False
msgbox "Writing " & line
ElseIf reItem.Test(line) Then
write_ini.WriteLine item & "=" & value
wrote = True
in_section = False
Else
write_ini.WriteLine line
End If
Else
write_ini.WriteLine line
End If
Wend

If section_exists = False Then ' section doesn't exist
section=trim(section)
item =trim(item)

write_ini.WriteLine
write_ini.WriteLine "[" & section & "]"
write_ini.WriteLine item & "=" & value
End If

read_ini.Close
write_ini.Close
FileSysObj.DeleteFile file
FileSysObj.MoveFile path & "temp_ini.ini", file
set reWSection=nothing
set reItem=nothing
End Sub

const taWindowHidden = 0
const taWindowShow = 1
const taWaitForFinish = True
const taDontWaitForFinish = False

Dim oSh
' NOTE: this section only works for regular clients. See below
' for the version for Terminal Server.
WriteIni "c:\winnt\jde.ini", "SIGNON", "LASTENV", "PD7333"

Set oSh = CreateObject("WScript.Shell")
oSh.run "oexplore", tsWindowShow, taDontWaitForFinish
set oSh = Nothing
' NOTE: remove the lines above and uncomment the following
' lines to use this with Terminal Server, where the JDE.INI
' is stored for each individual user.
'Set oSh = CreateObject("WScript.Shell")
'UserProfile = oSh.Environment("Process").item("USERPROFILE")
'WriteIni UserProfile & "\windows\jde.ini", "SIGNON", "LASTENV", "PD7333"
'oSh.run "oexplore", tsWindowShow, taDontWaitForFinish
'set oSh = Nothing
 
Back
Top