1. yasser Ali
  2. PowerBuilder
  3. Wednesday, 10 April 2019 18:51 PM UTC

i have a pb app runing on windows server2008 R2 64bit

when i use the PB "RUN" function it returns 1 but nothing is run

when debugging and copying the run string parameter to cmd prompt of server it runs successfully

i even made the app create a batch file and run it but i got same result , when i run batch file from explorer it runs successfuly

any idea

Brad Mettee Accepted Answer Pending Moderation
  1. Friday, 12 April 2019 15:13 PM UTC
  2. PowerBuilder
  3. # 1

How certain are you of the current directory? If you don't specify a fully qualified path, and the current working directory is different than expected, it will also fail to run the exe or bat file.

GetCurrentDirectory() will return the current working directory, and ChangeDirectory(string dirname) will let you set it.

Windows shortcuts can default the working directory to someplace different than the exe location. If you're running from a shortcut, and the "Start In" directory is different from the app dir, you'll see issues like this.

Things that can change working directory:

- "Start In" directory of the windows shortcut
- batch file with a "cd " in it
- OpenFile, SaveFile or similar dialog windows
- Using ChangeDirectory() function

To run external programs reliably, you'll need to use a fully qualified path, ChangeDirectory(), or make sure the target directory is in the windows search path (local user or system).

Hope this helps.

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 11 April 2019 18:56 PM UTC
  2. PowerBuilder
  3. # 2

Hi Yasser;

  If the ShellExecute does not work - even trying my Unicode suggestion - I have another alternative that I use in my STD framework that might work. Let me know and I can get you to try an example on W2008. If that works, I can help you adopt that external execution mechanism to your App.

Regards ... Chris

Comment
There are no comments made yet.
yasser Ali Accepted Answer Pending Moderation
  1. Thursday, 11 April 2019 11:29 AM UTC
  2. PowerBuilder
  3. # 3

thanks for your response

but unfortunately  i did try it and had the same result.

i didn't mention as i thought depending on PB fn. would be more reliable.

 

 

 

Comment
There are no comments made yet.
Marco Meoni Accepted Answer Pending Moderation
  1. Thursday, 11 April 2019 07:02 AM UTC
  2. PowerBuilder
  3. # 4

Hi Yasser,

I prefer to use ShellExecute() over Run() because it offers several actions, accepts content files, launches files within the associated program ID, and thereby is not only limited to fire off executable files like Run().
Give it a try and maybe you solve the issue on Win2008R2 64bit.

Run this code from a PB Window:

// external function declaration
FUNCTION long ShellExecute (uint  ihwnd,string  lpszOp, string  lpszFile,string  lpszParams, string  lpszDir,int  wShowCmd ) LIBRARY "Shell32.dll" ALIAS FOR "ShellExecuteA;ANSI" 

// specify operation against external file, pass parameters if needed, set basedir etc...
ll_rc = ShellExecute( handle(This), "open", "upload.bat", ls_parm, as_basedir, 0)

Best,

.m

 

P.S.

Microsoft docs at: https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-shellexecutea

Comment
  1. Chris Pollach @Appeon
  2. Thursday, 11 April 2019 14:12 PM UTC
Hi Yasser;



I would recommend what Marco suggests however, I would recommend implementing this as a Unicode command ...



Function long ShellExecute ( &

long hwindow, &

string lpOperation, &

string lpFile, &

string lpParameters, &

string lpDirectory, &

long nShowCmd &

) Library "shell32.dll" Alias for "ShellExecuteW"



Regards ... Chris
  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.