kidu11
asked on
how to know closing of one window within another
Hi
i am calling a batch file (.bat) file from one of my powerbuilder window. it will take bit seconds to fully execute the batch statements and it will close automatically.
now what i want is, i need to know closing of that dos mode window from my called powerbuilder window to show some message. how will i acheive it ?. if u can, pls give example codes..
is it possible to find with findwindowA API ?. but what will be the title of the batch file ?
any comment will be appreciated
kidu 11
i am calling a batch file (.bat) file from one of my powerbuilder window. it will take bit seconds to fully execute the batch statements and it will close automatically.
now what i want is, i need to know closing of that dos mode window from my called powerbuilder window to show some message. how will i acheive it ?. if u can, pls give example codes..
is it possible to find with findwindowA API ?. but what will be the title of the batch file ?
any comment will be appreciated
kidu 11
ASKER
hi
thanx 4 ur comment
shellexecuteA is not working 4 the program i am trying to run, that has parameters also. here is my code,
is_commandline = "command.com /c " + is_batfile + " " + is_workingfolder + " " + is_dbuid + " " + is_dbpwd + " " + is_zippwd + " " + is_span + " " + is_zipfile
//running the backup batchfile
if run( is_commandline , normal!) = 1 then
return 1
end if
so, what is the problem...i think shellexecuteA will not work files that has paremeters, am i correct ?.
then how will achieve this
kidu 11
thanx 4 ur comment
shellexecuteA is not working 4 the program i am trying to run, that has parameters also. here is my code,
is_commandline = "command.com /c " + is_batfile + " " + is_workingfolder + " " + is_dbuid + " " + is_dbpwd + " " + is_zippwd + " " + is_span + " " + is_zipfile
//running the backup batchfile
if run( is_commandline , normal!) = 1 then
return 1
end if
so, what is the problem...i think shellexecuteA will not work files that has paremeters, am i correct ?.
then how will achieve this
kidu 11
long hwnd
string filname
hwnd=handle(parent)
is_commandline = "command.com /c " + is_batfile + " " + is_workingfolder + " " + is_dbuid + " " + is_dbpwd + " " + is_zippwd + " " + is_span + " " + is_zipfile
Try This
ShellExecuteA(0,'open',is_ commandlin e ,'','',0)
Or Try This
shellexecuteA(hwnd,'open', is_command line ,'','',0)
ShellExcuteA work well for me with parameters. I run a command to bcp with parameters.
HTH
Namasi Navaretnam
string filname
hwnd=handle(parent)
is_commandline = "command.com /c " + is_batfile + " " + is_workingfolder + " " + is_dbuid + " " + is_dbpwd + " " + is_zippwd + " " + is_span + " " + is_zipfile
Try This
ShellExecuteA(0,'open',is_
Or Try This
shellexecuteA(hwnd,'open',
ShellExcuteA work well for me with parameters. I run a command to bcp with parameters.
HTH
Namasi Navaretnam
I am not sure of command.com is 16 bit or 32 bit. SO may want to try with cmd as well.
long hwnd
string filname
hwnd=handle(parent)
is_commandline = "cmd /c " + is_batfile + " " + is_workingfolder + " " + is_dbuid + " " + is_dbpwd + " " + is_zippwd + " " + is_span + " " + is_zipfile
Try This
ShellExecuteA(0,'open',is_ commandlin e ,'','',0)
Or Try This
shellexecuteA(hwnd,'open', is_command line ,'','',0)
ShellExcuteA work well for me with parameters. I run a command to bcp with parameters.
long hwnd
string filname
hwnd=handle(parent)
is_commandline = "cmd /c " + is_batfile + " " + is_workingfolder + " " + is_dbuid + " " + is_dbpwd + " " + is_zippwd + " " + is_span + " " + is_zipfile
Try This
ShellExecuteA(0,'open',is_
Or Try This
shellexecuteA(hwnd,'open',
ShellExcuteA work well for me with parameters. I run a command to bcp with parameters.
Hi
it is not working if any argument is there. it return a value 2 ( no path found ) if any space is there ( that is arguments)
for ex: u check this one in ur system
ShellExecuteA(0,'open','no tepad test.txt','','',1)
if it will be like ShellExecuteA(0,'open','no tepad','', '',1), then no pblm it is working fine, return a value >34
my OS is win98
pls check and let me know if any other method is there ?.
kidu11
it is not working if any argument is there. it return a value 2 ( no path found ) if any space is there ( that is arguments)
for ex: u check this one in ur system
ShellExecuteA(0,'open','no
if it will be like ShellExecuteA(0,'open','no
my OS is win98
pls check and let me know if any other method is there ?.
kidu11
You are right!!
I went and checked my previous code!! This is what I did
ls_commandfilename = "C:\test.bat"
ls_command = "commmand.... etc with your parameters"
Ll_FileNum = FileOpen ( Ls_CommandFileName, LineMode!, Write!, LockWrite!, Replace!)
FileWrite(ll_FileNum, Ls_Command)
FileClose(ll_FileNum)
Now execute,
Ll_Return = ShellExecuteA(0,'open',ls_ CommandFil eName,'',' ',0)
//make sure to use 0 as the last parameter.
HTH
Namasi Navaretnam
I went and checked my previous code!! This is what I did
ls_commandfilename = "C:\test.bat"
ls_command = "commmand.... etc with your parameters"
Ll_FileNum = FileOpen ( Ls_CommandFileName, LineMode!, Write!, LockWrite!, Replace!)
FileWrite(ll_FileNum, Ls_Command)
FileClose(ll_FileNum)
Now execute,
Ll_Return = ShellExecuteA(0,'open',ls_
//make sure to use 0 as the last parameter.
HTH
Namasi Navaretnam
At the end ,
FileDelete("c:\test.bat)
FileDelete("c:\test.bat)
ASKER
hi namasi
thank u.. i will check and get u back soon
kidu11
thank u.. i will check and get u back soon
kidu11
ASKER
thanx again
it is working now...but still my goal is not acheived !!. how do i know when the task is finished ?. i need to do some coding just after the task is finished... where will i code this
what i already done is checking the existance of the newly created file within a timer by the PB function fileexist() !!. really i expect there will be some method with shellexecute..get me abooooout it.
kidu
it is working now...but still my goal is not acheived !!. how do i know when the task is finished ?. i need to do some coding just after the task is finished... where will i code this
what i already done is checking the existance of the newly created file within a timer by the PB function fileexist() !!. really i expect there will be some method with shellexecute..get me abooooout it.
kidu
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Alternative,
Open a response window (that display "Backing Up Database or what ever") so that the code underneath will not get executed.
After opening the winodw post an event (using POSTEVENT function) to check the existance of done file. whenthe file exists you can close the response winodw.
Do While Lb_DoneFileFound = FALSE
If FileExists(Ls_DoneFile) then
Lb_DoneFileFound = TRUE
end if
Sleep(1) // Sleep for 1 second
Loop
HTH
Open a response window (that display "Backing Up Database or what ever") so that the code underneath will not get executed.
After opening the winodw post an event (using POSTEVENT function) to check the existance of done file. whenthe file exists you can close the response winodw.
Do While Lb_DoneFileFound = FALSE
If FileExists(Ls_DoneFile) then
Lb_DoneFileFound = TRUE
end if
Sleep(1) // Sleep for 1 second
Loop
HTH
Kidu11
Did that solution work?
Did that solution work?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Also,
to get the processid, the flag needs to be set before calling ShellExecuteEx:
CONSTANT long SEE_MASK_CLASSNAME =64 //&H40
lst_shellexecuteinfo.fMask = SEE_MASK_NOCLOSEPROCESS
Regards,
Vikas
to get the processid, the flag needs to be set before calling ShellExecuteEx:
CONSTANT long SEE_MASK_CLASSNAME =64 //&H40
lst_shellexecuteinfo.fMask
Regards,
Vikas
ASKER
Hi
Thank u Namasi.. it is working, but i will also check with Vikas's ShellExecuteEx, i think that will be a better approch
so i will get back to u soon
rgrds
kidu
Thank u Namasi.. it is working, but i will also check with Vikas's ShellExecuteEx, i think that will be a better approch
so i will get back to u soon
rgrds
kidu
Yes. I agree ShellExecuteEx would be a better approch.
ASKER
Hello vikas
now i checked with shellexecuteex and WaitForSingleObject. but the WaitForSingleObject is not working.
here is my complete code
CONSTANT long SEE_MASK_CLASSNAME = 64
CONSTANT long SW_NORMAL = 1
Integer WAIT_TIMEOUT = 258 //&H102
CONSTANT long SH_HIDE = 0
integer retval
string ls_class
string ls_extension
long ll_ret
os_shellexecuteinfo lst_shellexecuteinfo
// Search for the classname associated with extension
RegistryGet("HKEY_CLASSES_ ROOT\" + '.bat', "", ls_class)
// the file is not associated with any program.. try to install the program
IF isNull(ls_class) OR Trim(ls_class) = "" THEN
RETURN 0
END IF
as_file = is_commandline = "command.com /c " + is_batfile + " " + is_workingfolder + " " + is_dsnname + " " + is_dbuid + " " + is_dbpwd + " " + is_zipfile
lst_shellexecuteinfo.cbsiz e = 60
lst_shellexecuteinfo.fMask = SEE_MASK_CLASSNAME // Use classname
lst_shellexecuteinfo.hwnd = 0
lst_shellexecuteinfo.lpVer b = "open"
lst_shellexecuteinfo.lpfil e = as_file
lst_shellexecuteinfo.lpCla ss = ls_class
lst_shellexecuteinfo.nShow = SH_HIDE
ll_ret = ShellExecuteEx(lst_shellex ecuteinfo)
// cannot open the file...pls try reinstalling the program
IF ll_ret = 0 THEN
RETURN 2
END IF
Do
retval = WaitForSingleObject(lst_sh ellexecute info.hProc ess, 0)
loop while retval = WAIT_TIMEOUT
return 1
in the above code the problem is the do loop is iterating only once. and its value at the first iteration is -1. so what is the problem, pls check inform me what is wrong with the above code
thanx
kidu
now i checked with shellexecuteex and WaitForSingleObject. but the WaitForSingleObject is not working.
here is my complete code
CONSTANT long SEE_MASK_CLASSNAME = 64
CONSTANT long SW_NORMAL = 1
Integer WAIT_TIMEOUT = 258 //&H102
CONSTANT long SH_HIDE = 0
integer retval
string ls_class
string ls_extension
long ll_ret
os_shellexecuteinfo lst_shellexecuteinfo
// Search for the classname associated with extension
RegistryGet("HKEY_CLASSES_
// the file is not associated with any program.. try to install the program
IF isNull(ls_class) OR Trim(ls_class) = "" THEN
RETURN 0
END IF
as_file = is_commandline = "command.com /c " + is_batfile + " " + is_workingfolder + " " + is_dsnname + " " + is_dbuid + " " + is_dbpwd + " " + is_zipfile
lst_shellexecuteinfo.cbsiz
lst_shellexecuteinfo.fMask
lst_shellexecuteinfo.hwnd = 0
lst_shellexecuteinfo.lpVer
lst_shellexecuteinfo.lpfil
lst_shellexecuteinfo.lpCla
lst_shellexecuteinfo.nShow
ll_ret = ShellExecuteEx(lst_shellex
// cannot open the file...pls try reinstalling the program
IF ll_ret = 0 THEN
RETURN 2
END IF
Do
retval = WaitForSingleObject(lst_sh
loop while retval = WAIT_TIMEOUT
return 1
in the above code the problem is the do loop is iterating only once. and its value at the first iteration is -1. so what is the problem, pls check inform me what is wrong with the above code
thanx
kidu
Hi kidu,
I tried with a .txt file, and it worked fine... the function kept returning 258 till the notepad was open, and once I closed the notepad, it returned 0..
you can try the following :
1.change the following :
lst_shellexecuteinfo.nShow = SH_SHOW //SH_HIDE -- SH_SHOW =1
2. check if the lst_shellexecuteinfo.hProc ess has a process id.
3. instead of using "command.com /c", try opening just the batch file, and pass the parameters in the lpParameters member.
will try to test with a .bat file
regards,
Vikas D
I tried with a .txt file, and it worked fine... the function kept returning 258 till the notepad was open, and once I closed the notepad, it returned 0..
you can try the following :
1.change the following :
lst_shellexecuteinfo.nShow
2. check if the lst_shellexecuteinfo.hProc
3. instead of using "command.com /c", try opening just the batch file, and pass the parameters in the lpParameters member.
will try to test with a .bat file
regards,
Vikas D
Function long ShellExecuteA( long hWindow, string Operation, string File, string Parameters, string Directory, long Visible) Library 'shell32'
See example below:
Use shellExecute API method :
// Add this to local/global external functions
//FUNCTION long ShellExecuteA(long hwnd, string lpOperation, string lpFile, string lpParameters, string lpDirectory, long nShowCmd) LIBRARY "SHELL32.DLL"
// API call script
long hwnd
string filname
hwnd=handle(parent)
filname='app2.exe'
shellexecuteA(hwnd,'open',
HTH
Namasi Navaretnam