|
-
Oct 28th, 2002, 10:44 PM
#1
Thread Starter
Hyperactive Member
Closing a command window [RESOLVED]
Guys,
I really need help on closing a command window that i have created using the following code:
VB Code:
Public Function ExecCmd(cmdline$)
Dim proc As PROCESS_INFORMATION
Dim start As STARTUPINFO
Dim ret&
start.cb = Len(start)
ret& = CreateProcessA(0&, cmdline$, 0&, 0&, 1&, NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc)
ret& = WaitForSingleObject(proc.hProcess, INFINITE)
ret& = CloseHandle(proc.hProcess)
End Function
This is the usage of it:
VB Code:
Call ExecCmd(App.Path & "\rar a " & rarName & ".rar " & "*.*")
Now the problem is that when i run the code on my XP machine it works perfectly, the window appears and compresses my files and then automatically closes itself. However, when i run it on a Win2K machine, the window appears, but does not close itself, rather i have to close it manually, which i don't want my users to have to do.
Can anyone tell me why this code doesn't perform on 2K, or if there is a way to check if the window has closed and close it if it hasn't closed?
Any help with this problem would be greatly appreciated, my boss is practically screaming for this to be finished.
Last edited by Blinky Bill; Oct 29th, 2002 at 07:48 PM.
We don't know what's wrong. . . So the best bet might be to remove something surgically.
-
Oct 28th, 2002, 10:49 PM
#2
Frenzied Member
What's the program you're using to do this?
-
Oct 28th, 2002, 10:51 PM
#3
Thread Starter
Hyperactive Member
A compression program called 'rar'
We don't know what's wrong. . . So the best bet might be to remove something surgically.
-
Oct 29th, 2002, 12:48 AM
#4
Thread Starter
Hyperactive Member
We don't know what's wrong. . . So the best bet might be to remove something surgically.
-
Oct 29th, 2002, 04:58 AM
#5
Frenzied Member
Debugging needed:
VB Code:
Public Function ExecCmd(cmdline$)
Dim proc As PROCESS_INFORMATION
Dim start As STARTUPINFO
Dim ret&
start.cb = Len(start)
'What is START at this point? Is it sensible?
'What is cmdline$ at this point? Is it correct and sensible?
ret& = CreateProcessA(0&, cmdline$, 0&, 0&, 1&, NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc)
'What is ret& at this point? Is it sensible?
' Has the process started correctly?
' What is proc at this point? Is it sensible?
' What is proc.hProcess at this point? Is it sensible?
ret& = WaitForSingleObject(proc.hProcess, INFINITE)
'What is ret& at this point? Is it sensible?
ret& = CloseHandle(proc.hProcess)
'What is ret& at this point? Is it sensible?
End Function
-
Oct 29th, 2002, 06:05 PM
#6
Thread Starter
Hyperactive Member
cmdline$ is good and proper, because it works fine on every system. The program works fine on XP, i just tested it on another XP system, so i think it doesn't work on 98, 2K, etc. Is there some other method to achieve what i want that works on the older oses?
Unfortunately, i cannot test on the 2K system because it has gone walkies for the day.
We don't know what's wrong. . . So the best bet might be to remove something surgically.
-
Oct 29th, 2002, 07:30 PM
#7
Thread Starter
Hyperactive Member
Okay, i've just managed to test the code on the 2K machine, and i get identical results as on the XP machine, but the program doesn't close automatically.
What happens is that in the following code
VB Code:
Public Function ExecCmd(cmdline$)
Dim proc As PROCESS_INFORMATION
Dim start As STARTUPINFO
Dim ret&
start.cb = Len(start)
MsgBox (start.cb)
ret& = CreateProcessA(0&, cmdline$, 0&, 0&, 1&, NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc)
MsgBox (ret&)
ret& = WaitForSingleObject(proc.hProcess, INFINITE)
MsgBox (ret&)
ret& = CloseHandle(proc.hProcess)
MsgBox (ret&)
End Function
i get the values 68, 1, 0, 1 on both systems, but i have to close the external app before i get the last two values.
Does anyone know what this means? Cause i'm banging my head against a brick wall here at the moment.
We don't know what's wrong. . . So the best bet might be to remove something surgically.
-
Oct 29th, 2002, 07:47 PM
#8
Thread Starter
Hyperactive Member
Okay, thanx guys, but i finally got a solution to the problem, well a hack to solve this one, but whatever works right?
What i ended up doing was creating a pif file for the dos program i am running that told the os to close it on exit. Don't know why the code i was given didn't do exactly that like it was supposed to, but anyway, it works and that is a good thing.
Thanx all for the help.
We don't know what's wrong. . . So the best bet might be to remove something surgically.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|