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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run in background & Shutdown

Status
Not open for further replies.

iranor

Programmer
Joined
Jun 17, 2004
Messages
174
Location
CA
I searched on the web for like 2-3 hours without finding what I was looking for. The first is a command to hide the application as soon as it is launched, without user implication. I have no problem using "Me.Hide()" in a button click event, but it won't do anything in Form1_Load.

The second is a way to shutdown the computer without having to use shutdown.exe (It only has to work on Windows XP...) I have to create a small application to prevent students to use applications like limewire or msn messenger while attending classes... the reboot is just in case they find the executable.
 
Me.Hide needs to run from the Form_Activate event. Within Form_Load, the form isn't yet loaded so there's nothing to hide. If you really don't want anything to be visible to the user, why not just create a formless exe that has no visible presence?

You can shut down the computer with

Shell "ShutDown -s -t 00"

or you can shutdown and restart with

Shell "ShutDown -r -t 00"
 
I agree with Golom.

To implement his suggestion, you need to have a module in your project. In the module, you create a public subroutine called Main.

Ex...

Code:
public Sub Main()

  Call Msgbox("Hello World")

End Sub

Then, click Project -> Properties. On the general tab, change the Startup Object to 'Sub Main'



-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Or if you simply remove the start up object from the project, the new startup object will be Sub Main.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top