1. Samuel Sanchez Avila
  2. PowerBuilder
  3. Thursday, 13 February 2020 18:08 PM UTC

Hello there.

I have an idea, but i dont know how to solve...

1 - There´s one server computer, and 10 client computers (random number) connecting to the server computer

2 - One app that have getcurrentdirectory and getcontextservice methods

3 - Leave that app in the server computer and the others 10 computers, accessing to the app with direct access...

The issue is:

Both Methods are getting user-path from the server computer and not from the client computers

The question is:

Is there a way to have the user-path from each computer, leaving the main app at the server computer?

 

Thanks....

Accepted Answer
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Thursday, 13 February 2020 19:01 PM UTC
  2. PowerBuilder
  3. # Permalink

From: https://groups.google.com/forum/#!msg/sybase.public.powerbuilder.powerscript/4ZN-cY-j7og/Daa15nOzjbUJ

 

String ls_path

RegistryGet("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explore
r\Shell Folders", "Desktop", RegString!, ls_path )        

If IsNull(ls_path) then
        ls_path = ""
End If

If ls_path = "" then
        ls_path = "C:\Documents and Settings\" + g_s_userid + "\Desktop"
End If

Return ls_path

Comment
  1. Miguel Leeuwe
  2. Thursday, 13 February 2020 23:48 PM UTC
Agree with John. His way is a bit cleaner.
  1. Helpful
  1. Veera Venkata
  2. Tuesday, 26 September 2023 10:49 AM UTC
Hi,

I faced the same issue now,



tried with the above code. still the directory opening as server computer instead of user computer path.

I'm using PB 12.1 and deployed the application into IIS server.

tried with PB web forms as well. please suggest.

how to get the user computer directory instead of server directory in PB WEB.

  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Thursday, 13 February 2020 22:09 PM UTC
  2. PowerBuilder
  3. # 1

Here's an example of how you can obtain the user profile path without mucking around in the Windows Registry:

Integer li_numvalues
ContextKeyword lcx_key
String ls_values[]

GetContextService('ContextKeyword',lcx_key)
li_numvalues = lcx_key.GetContextKeywords('UserProfile',ls_values)
if li_numvalues > 0 then
MessageBox('UserProfile',ls_values[1])
else
MessageBox('UserProfile','Not found')
end if

Regards,
John

Comment
  1. Juan Pedro Sanz Diez
  2. Wednesday, 30 September 2020 10:35 AM UTC
I have this code for pb and works fine. But in powerser web is not supported. Any workarround to get it?
  1. Helpful
  1. Veera Venkata
  2. Tuesday, 26 September 2023 10:51 AM UTC
Hi,

I faced the same issue now,



tried with the above. still the directory opening as server computer instead of user computer path.

in local it's working fine, but after deployment it's getting msg as not found for the msg box.

I'm using PB 12.1 and deployed the application into IIS server.

tried with PB web forms as well. please suggest.

how to get the user computer directory instead of server directory in PB WEB.

  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 13 February 2020 22:07 PM UTC
  2. PowerBuilder
  3. # 2

Hi Samuel;

  Yes, your PB Apps should always do that. Here is what my framework does at start-up ...

 

I think what your looking for might be the APPDATA setting for each user that invokes your App. Correct?

Regards ... Chris

Comment
  1. Samuel Sanchez Avila
  2. Thursday, 13 February 2020 23:41 PM UTC
Yes, That is what im looking for, for each one
  1. Helpful
  1. Chris Pollach @Appeon
  2. Friday, 14 February 2020 03:17 AM UTC
Hi Samuel ... You can get the code from the STD framework. The framework code is free & open source. You can download it from here ...

https://sourceforge.net/projects/stdfndclass/

Let me know if you need help locating any specific code segment.
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Thursday, 13 February 2020 18:52 PM UTC
  2. PowerBuilder
  3. # 3

Maybe you can get the user -path from the registry?

Comment
  1. Samuel Sanchez Avila
  2. Thursday, 13 February 2020 18:54 PM UTC
With RegistryGet / RegistryKeys / RegistryValue Methods?

How could it be?
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Thursday, 13 February 2020 18:47 PM UTC
  2. PowerBuilder
  3. # 4

The problem with GetCurrentDirectory is that it gets the current directory:

The moment you run an executable, windows' internal directory changed to that directory ( or to the folder of "start in" of a shortcut).

So long story short, I don't know how to solve your problem.

Comment
There are no comments made yet.
Michael Kramer Accepted Answer Pending Moderation
  1. Thursday, 13 February 2020 18:36 PM UTC
  2. PowerBuilder
  3. # 5

I'm not sure what you mean by "user-path". Can you give an explicit example?

Anyways, this sounds like app behavior when settings read from .INI or other .config file stored in same folder as app's executable. Alternatives:

  1. Set environment variables
  2. Map drive letters
  3. Set registry values at local machine / current user, -or-
  4. Use Windows' GetKnownFolder API to lookup varying folder names

There are many examples on (D) in PowerScript code in case you opt for that alternative. It requires use of GUID values and knowledge of which WIN API to call. I used this option to test C# interop in PB 2019 R2.

HTH /Michael

 

Comment
  1. Samuel Sanchez Avila
  2. Thursday, 13 February 2020 18:45 PM UTC
User Path...

Computer 1: C:\Users\Person1\App\app_direct_access.exe

Computer 2: C:\Users\Person2\App\app_direct_access.exe

Computer 3: C:\Users\Person3\App\app_direct_access.exe

.

.

.

I want to get C:\Users\PersonX.

Leaving the app.exe in the server computer where those computers connect

I getting: C: \Users\Server_Computer_Name\
  1. Helpful
  1. Michael Kramer
  2. Thursday, 13 February 2020 21:06 PM UTC
Check environment variables %HOMEDRIVE% and %HOMEPATH%. Combine into one string and let your app change folder to that folder name -- ?
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.