Automatic shutdown of application when windows is shutdown 
Author Message
 Automatic shutdown of application when windows is shutdown

Dear Experts,

Hello,

I am coding in VB 6. I wish my application to shutdown automatically
when Windows 2000 is shut down. Unfortunately application is not
shutting down automatically.

I investigated and found that the following code is not allowing the
application to shutdown.
This code is written in Form_Unload event, which is essentail to be
exectued before exiting the application.

  Dim xlApplication as Object

'
' Get Excel application object or create it
'
  Set xlApplication = GetObject("", "Excel.Application")
  If Err <> 0 Then
    Err.Clear
    Set xlApplication = CreateObject("Excel.Application")
  End If
'
' Restore Excel default file path
'
  If Err = 0 Then
    xlApplication.DefaultFilePath = gXLDefaultFilePath
  End If

  Set xlApplication = Nothing

Thanks in advance for any assistance.

Regards,

Faiz



Sun, 22 Aug 2004 13:45:42 GMT  
 Automatic shutdown of application when windows is shutdown
Windows is probably not going to allow you to create the Excel process
during shutdown.  You might try keeping a cached instance of Excel around if
this is essential.  And you may want to do this in Form_QueryUnload instead
so you can inform the user and cancel the unload if it fails.

-------------------------------------------------
Automate your software builds with Visual Build
http://www.kinook.com


Quote:
> Dear Experts,

> Hello,

> I am coding in VB 6. I wish my application to shutdown automatically
> when Windows 2000 is shut down. Unfortunately application is not
> shutting down automatically.

> I investigated and found that the following code is not allowing the
> application to shutdown.
> This code is written in Form_Unload event, which is essentail to be
> exectued before exiting the application.

>   Dim xlApplication as Object

> '
> ' Get Excel application object or create it
> '
>   Set xlApplication = GetObject("", "Excel.Application")
>   If Err <> 0 Then
>     Err.Clear
>     Set xlApplication = CreateObject("Excel.Application")
>   End If
> '
> ' Restore Excel default file path
> '
>   If Err = 0 Then
>     xlApplication.DefaultFilePath = gXLDefaultFilePath
>   End If

>   Set xlApplication = Nothing

> Thanks in advance for any assistance.

> Regards,

> Faiz



Sun, 22 Aug 2004 22:14:40 GMT  
 Automatic shutdown of application when windows is shutdown
Thanks for taking interest. I have already tested the following block
of code in QueryUnload event, but could not get the desired result.
Actually when windows is shutting down I can't allow my application to
wait for the creation of Excel process and then inform the user about
failure or success. I just expect my application to quickly finish the
tasks and exit while the windows shout down process is in progress.

Any idea?

Regards,

Faiz

Quote:

> Windows is probably not going to allow you to create the Excel process
> during shutdown.  You might try keeping a cached instance of Excel around if
> this is essential.  And you may want to do this in Form_QueryUnload instead
> so you can inform the user and cancel the unload if it fails.

> -------------------------------------------------
> Automate your software builds with Visual Build
> http://www.kinook.com



> > Dear Experts,

> > Hello,

> > I am coding in VB 6. I wish my application to shutdown automatically
> > when Windows 2000 is shut down. Unfortunately application is not
> > shutting down automatically.

> > I investigated and found that the following code is not allowing the
> > application to shutdown.
> > This code is written in Form_Unload event, which is essentail to be
> > exectued before exiting the application.

> >   Dim xlApplication as Object

> > '
> > ' Get Excel application object or create it
> > '
> >   Set xlApplication = GetObject("", "Excel.Application")
> >   If Err <> 0 Then
> >     Err.Clear
> >     Set xlApplication = CreateObject("Excel.Application")
> >   End If
> > '
> > ' Restore Excel default file path
> > '
> >   If Err = 0 Then
> >     xlApplication.DefaultFilePath = gXLDefaultFilePath
> >   End If

> >   Set xlApplication = Nothing

> > Thanks in advance for any assistance.

> > Regards,

> > Faiz



Mon, 23 Aug 2004 13:37:23 GMT  
 Automatic shutdown of application when windows is shutdown


Quote:
> Thanks for taking interest. I have already tested the following block
> of code in QueryUnload event, but could not get the desired result.
> Actually when windows is shutting down I can't allow my application to
> wait for the creation of Excel process and then inform the user about
> failure or success. I just expect my application to quickly finish the
> tasks and exit while the windows shout down process is in progress.

> Any idea?

Check the UnloadMode property in Form_QueryUnload


Mon, 23 Aug 2004 13:59:20 GMT  
 Automatic shutdown of application when windows is shutdown

Quote:



> > Thanks for taking interest. I have already tested the following block
> > of code in QueryUnload event, but could not get the desired result.
> > Actually when windows is shutting down I can't allow my application to
> > wait for the creation of Excel process and then inform the user about
> > failure or success. I just expect my application to quickly finish the
> > tasks and exit while the windows shout down process is in progress.

> > Any idea?

> Check the UnloadMode property in Form_QueryUnload

I have already checked UnloadMode property in Form_QueryUnload event,
but it does not matter. Actually problem arises when Excel object is
created to restore the default path while quitting the application,
which is also necessary. Probably windows does not allow any object to
create while shut down is in progress. So I am looking for an
alternate to over come this problem.

Regards,

Faiz



Tue, 24 Aug 2004 12:33:19 GMT  
 Automatic shutdown of application when windows is shutdown
Wellllllll,  If you only want to restore a default path in Excel, would it
not be possible to write the default value directly into the appropriate
registry key.

This would have the added benefit of being far faster than waiting for the
Excel object to load.

Matt



Quote:


> > > Thanks for taking interest. I have already tested the following block
> > > of code in QueryUnload event, but could not get the desired result.
> > > Actually when windows is shutting down I can't allow my application to
> > > wait for the creation of Excel process and then inform the user about
> > > failure or success. I just expect my application to quickly finish the
> > > tasks and exit while the windows shout down process is in progress.

> > > Any idea?

> > Check the UnloadMode property in Form_QueryUnload

> I have already checked UnloadMode property in Form_QueryUnload event,
> but it does not matter. Actually problem arises when Excel object is
> created to restore the default path while quitting the application,
> which is also necessary. Probably windows does not allow any object to
> create while shut down is in progress. So I am looking for an
> alternate to over come this problem.

> Regards,

> Faiz



Sat, 28 Aug 2004 18:31:45 GMT  
 Automatic shutdown of application when windows is shutdown
Thanks for your suggestion. Although the solution looks good but it
needs certain clarifications. First of all DefaultPath entries are
found at the following places so which one should be altered.

HKEY_CURRENT_USER/Software/Microsoft/Office/9.0/Excel/DefaultPath
HKEY_USERS/HKEY_USERS\S-1-5-21-1169439278-1636400164-1637365974-1007/Software/Microsoft/Office/9.0/Excel/DefaultPath

Secondly it is also holding Microsoft office version (which is 9.0
here) and it is not confirmed that every user will have the same
office version, i.e. users can have different version of Microsoft
office installed on their PCs. So in latter case this solution does
not seem viable.

Any work around!

Regards,

Faiz

Quote:

> Wellllllll,  If you only want to restore a default path in Excel, would it
> not be possible to write the default value directly into the appropriate
> registry key.

> This would have the added benefit of being far faster than waiting for the
> Excel object to load.

> Matt







> > > > Thanks for taking interest. I have already tested the following block
> > > > of code in QueryUnload event, but could not get the desired result.
> > > > Actually when windows is shutting down I can't allow my application to
> > > > wait for the creation of Excel process and then inform the user about
> > > > failure or success. I just expect my application to quickly finish the
> > > > tasks and exit while the windows shout down process is in progress.

> > > > Any idea?

> > > Check the UnloadMode property in Form_QueryUnload

> > I have already checked UnloadMode property in Form_QueryUnload event,
> > but it does not matter. Actually problem arises when Excel object is
> > created to restore the default path while quitting the application,
> > which is also necessary. Probably windows does not allow any object to
> > create while shut down is in progress. So I am looking for an
> > alternate to over come this problem.

> > Regards,

> > Faiz



Sun, 29 Aug 2004 13:07:26 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Automatic Shutdown of Application when Windows is shutdown

2. Automatic shutdown of application when windows is shutdown

3. Automatic shutdown of application when windows is shutdown

4. Automatic shutdown of application when windows is shutdown

5. Automatic shutdown of application when windows is shutdown

6. Automatic Start and shutdown an application !

7. No Shutdown Event in a Windows Service Application?

8. How to ShutDown Windows from a VB application???

9. How to ShutDown Windows from a VB application???

10. automatic shutdown

11. Defrag routine with automatic shutdown

12. automatic shutdown...

 

 
Powered by phpBB® Forum Software