954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Make a VB Program run in the background?

Hi Everybody,

Sorry If i'm a bit of a noob at this. I'm wondering how to make a VB Program run in the background...If anybody knows how or has some code that would be great. Thanks for the help!

JBD2

JBD2
Newbie Poster
24 posts since Mar 2005
Reputation Points: 10
Solved Threads: 0
 

you can make it run in the background by merely hiding the form. If you stick a timer on the form, then you can have it cycle to do something every so often. In the form load's procedure just add:

me.visible = false
Comatose
Taboo Programmer
Team Colleague
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
 

Awesome!!Thanks!

JBD2
Newbie Poster
24 posts since Mar 2005
Reputation Points: 10
Solved Threads: 0
 

Ok, Thanks for telling me that, and sorry these questions don't have anything to do with the topic but, what would I put in if I wanted my program to run when windows starts up? Thanks.

JBD2
Newbie Poster
24 posts since Mar 2005
Reputation Points: 10
Solved Threads: 0
 
Ok, Thanks for telling me that, and sorry these questions don't have anything to do with the topic but, what would I put in if I wanted my program to run when windows starts up? Thanks.

You can make your program edit the registry on form load.... and then call your EXE. It's a good idea to give the user this option in an option form, or msgbox, so they know you are going to do this (I hate when programs try to force startup on me...)

dim wsh
set wsh = createobject("WScript.Shell")
Wsh.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\Run\MyProgName", "c:\path2yourprogram.exe"


Obviously You need to change 2 things in the last line... you need to change "MyProgName" to whatever the name of your application is.... and you need to change "c:\path2yourprogram.exe" to the path where your program is installed. That should have it load on startup.

Comatose
Taboo Programmer
Team Colleague
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
 

Thanks for the help.

JBD2
Newbie Poster
24 posts since Mar 2005
Reputation Points: 10
Solved Threads: 0
 

Hi,

Sorry this is off topic but but i am quite a newbie to this. can i shell a program behind the VB Program? or make the shelled program hidden?


Tx

Jay

jayshah
Newbie Poster
1 post since Aug 2005
Reputation Points: 10
Solved Threads: 0
 

i do not wish to offend you or make any accusations
but it sounds as if you want the program to go undetected hmmmmm very suspicous

;D

scrypt3r
Junior Poster
114 posts since Aug 2007
Reputation Points: 6
Solved Threads: 2
 

You can make your program edit the registry on form load.... and then call your EXE. It's a good idea to give the user this option in an option form, or msgbox, so they know you are going to do this (I hate when programs try to force startup on me...)

dim wsh
set wsh = createobject("WScript.Shell")
Wsh.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\Run\MyProgName", "c:\path2yourprogram.exe"

Obviously You need to change 2 things in the last line... you need to change "MyProgName" to whatever the name of your application is.... and you need to change "c:\path2yourprogram.exe" to the path where your program is installed. That should have it load on startup.


how do you remove it from the start-up list. because i wrote a program to annoy my friends little brother and i tried the startup thing and now i have a very annoying program that runs every time my computer starts. its not a huge deal 2 just close tthe program every time but i would prefer to not have to do that.

mandango5
Newbie Poster
1 post since Mar 2008
Reputation Points: 10
Solved Threads: 0
 

Go to start->run and type 'regedit'
Now find the folder in your registry:
HKLM\Software\Microsoft\Windows\CurrentVersion\Run\
and remove the key that your program wrote here.

Nick Evan
Not a Llama
Moderator
10,112 posts since Oct 2006
Reputation Points: 4,142
Solved Threads: 403
 

nick already answer your question. go to registry and delete the current file there.
or you can use msconfig manager.
go to start->run and type 'msconfig'.
click on startup tab then enable the files on list.

Jx_Man
Nearly a Senior Poster
3,329 posts since Nov 2007
Reputation Points: 1,372
Solved Threads: 444
 

You can make your program edit the registry on form load.... and then call your EXE. It's a good idea to give the user this option in an option form, or msgbox, so they know you are going to do this (I hate when programs try to force startup on me...)

dim wsh
set wsh = createobject("WScript.Shell")
Wsh.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\Run\MyProgName", "c:\path2yourprogram.exe"

Obviously You need to change 2 things in the last line... you need to change "MyProgName" to whatever the name of your application is.... and you need to change "c:\path2yourprogram.exe" to the path where your program is installed. That should have it load on startup.


Comatose: You have helped me out on this to. I am making a program that will clean up registry and is a sort of a script blocker for files....
I made it a feature where you can have it start when Windows starts or you can disable that. but i am having trouble disabling it. i used the code you gave to enable it (dim wsh
set wsh = createobject("WScript.Shell")
Wsh.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\Run\MyProgName", "c:\path2yourprogram.exe")
but is there a code you undew that?

Christkdcdd
Newbie Poster
2 posts since May 2009
Reputation Points: 10
Solved Threads: 0
 
Go to start->run and type 'regedit' Now find the folder in your registry: HKLM\Software\Microsoft\Windows\CurrentVersion\Run\ and remove the key that your program wrote here.


Ok, but is there a way to do it in visual basic? I am making a program that is like script blocking for files and i want the user to be able to enable or disable it at a click of a button with out going into regedit....
Is there a code to disable this is vb?

Christkdcdd
Newbie Poster
2 posts since May 2009
Reputation Points: 10
Solved Threads: 0
 

send me the entire code to run a application in background.

sasankkanda
Newbie Poster
1 post since Dec 2009
Reputation Points: 10
Solved Threads: 0
 

ummm how to you make it come back after this??????

321mm
Newbie Poster
1 post since Feb 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You