Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

run on shutdown

Status
Not open for further replies.

jozino01

Technical User
Apr 25, 2003
257
CA
hi, i was looking for program which would allow run a program/batch on shutdown (enabled in xp professional) in 98/2000/xp home.
there is one application shutdown folder lite, but it wasn't working for us. so i built simple shutdown program using sample code from vbnet.org.
i added there the following code:

Dim RETVAL As Variant
RETVAL = Shell("c:\exit.bat", 1)

where exit.bat is:

RD /S /q "C:\Documents and Settings\Owner\Local Settings\History"
RD /S /q "C:\Documents and Settings\Default User\Local Settings\History"
RD /S /q "D:\Temp\"
xcopy c:\dinsys\*.* g:\backup\*.*

the problem is that shutdown ends before this exit.bat is done. what would be the best way to deal with this issue, please?
 
use;


shutdown -a
to abort the shutdown process as the batch job starts.

and

shutdown -s -c "Computer is now shutting down"
to shutdown when the batch job finishes.



Chris.

Indifference will be the downfall of mankind, but who cares?
Woo Hoo! the cobblers kids get new shoes.
People Counting Systems

So long, and thanks for all the fish.
 
can i use it in this code?


Private Sub Command1_Click()

Dim uflags As Long
Dim success As Long
Dim RETVAL As Variant

RETVAL = Shell("c:\exit.bat", 1)

If Option1.Value = True Then uflags = EWX_LOGOFF
If Option2.Value = True Then uflags = EWX_SHUTDOWN
If Option3.Value = True Then uflags = EWX_REBOOT
If Option4.Value = True Then uflags = EWX_POWEROFF

Call ExitWindowsEx(uflags, 0&)

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top