Startup a winform hidden

  • Thread starter Thread starter Alison Givens
  • Start date Start date
A

Alison Givens

Hi there,

I have a small app, that copies some files to the server for backup, as soon
as the user exits Windows.
I want this form to startup hidden, so for the user it is not visible and
he/she can't close it.
How do I do this?

thanx,
Alison
 
If you put the form in it's own Thread and start this Thread with the .Show
function...one way to do it...

Btw: does anyone know how to show a Form in its own Thread but make it
visible. When I do this it won't give me an error but the form won't show
up...

Josef
 
This is code that compiles but I'm not sure if you can work with this to
solve your problem...give it a try

Imports System.Threading

Public Class Form1

Private SecondForm As Form

Private TheThread As Thread



Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

SecondForm = New Form

TheThread = New System.Threading.Thread(AddressOf SecondForm.Show)

TheThread.IsBackground = True

TheThread.Name = "My second form"

TheThread.Start()

End Sub

End Class
 
Alison Givens said:
I have a small app, that copies some files to the server for backup, as
soon as the user exits Windows.
I want this form to startup hidden, so for the user it is not visible and
he/she can't close it.

Change the project type to console application or simply do not show the
form in your project's 'Sub Main'.
 
mrs wagner

do u know vb?? i think u dont cos u alwayys copy overs samplles and call is
your own work. then u put it on yourr website
 
Sheep Shagger,
do u know vb?? i think u dont cos u alwayys copy overs samplles and call
is
your own work. then u put it on yourr website
If he does that, than he is mostly very well able to create those himself.

I can assure you as well from other VBNet discussiongroups that Herfried is
one of the greatest VBNet experts. Which does not mean that he covers *all*
aspects of dotNet as an Expert. Although his general knowledge of that is
absolute much more than average.

Cor
 
Can somebody please help me out with my question, since that is the purpose
of the newsgroup....lol
 
An extra problem occurred.
The code that copies the files, when windows shuts down, only works in
VB.NET2005
Anybody an idea how I get this working? (I can only work here with
VB.NET2003, because of license issues.)

Private Sub Form1_Closing(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles MyBase.Closing


If e.CloseReason = CloseReason.WindowsShutDown Then
Dim l_processInfo As System.Diagnostics.ProcessStartInfo
Dim l_process As System.Diagnostics.Process
l_processInfo = New
System.Diagnostics.ProcessStartInfo("c:\copy.bat")
l_processInfo.UseShellExecute = True
l_processInfo.WindowStyle = ProcessWindowStyle.Hidden
l_process = System.Diagnostics.Process.Start(l_processInfo)
Do Until l_process.HasExited
System.Threading.Thread.CurrentThread.Sleep(100)
Loop
Application.Exit()
End If

End Sub
 
Alison,
Can somebody please help me out with my question, since that is the
purpose of the newsgroup....lol
Every newsgroup on Usenet is a disscussion forum. In this case to improve
the use of VisualBasic with dotnet for the ones participate in it.

That can be with helping each other with questions. However it is not
limited to that it can be as well an open discussion while a question can
start a discussion.

Cor
 
Alison,

I think that you would first have to make to everybody clear what you mean
with "as soon as the user exit windows".

As I see the answers, than do the others have the same problem with that as
me

Cor
 
Ok, Cor I will try to explain the problem.

In the netwerk environment, there still are users that place some of their
files on the local disk.
What I want is that when the user shuts down his/her pc at the end of the
day, a file called copy.bat is started.
In this batch file the need files will be copied to the server.
The app I want to do this with, has to be invisible, so the user cannot
close it.
It also needs some kind of a timer function, so that the pc isn't shut down
before the files are copied.

I hope this is enough info.

Kind regards,
Alison
 
Ok, I get the point.
Let me put it like this than, I don't think it is a place to call somebody
sheep shagger, when he helps out other people with problems.
 
Ok, I get the point.
Let me put it like this than, I don't think it is a place to call somebody
sheep shagger, when he helps out other people with problems.
Nobody is calling somebody a sheep shagger, that is the Nick the one who has
sent the message is using.

Cor
 
Yes I noticed, but my message was sent allready.
He was called Mrs Wagner, not sheep shagger.
 
Alison,

Now I get what you want. In my idea will in this probably more a VBS
solution help you than a VBNet solution.

A short search in the newsgroup using Google gave me this

http://groups.google.com/group/micr...er+shut+down+XP&rnum=1&hl=en#fa0df0bbfad969cf

By the way, you cannot start a windowform (using the standard form) hidden.
It will always try to activate the form. Or you should try Herfried
workaround for that given in this message thread.

I hope this helps,

Cor
 
I am not sure what you mean by, it is more VBS.
Can I use this code in VB.NET2003, when I use it to make a windows
application?

Alison
 
Alison,

I mean that a window application for what you ask is not simple.

As somebody has answered you as well in this message thread, probably do you
need a windowservice. However in my opinion is for this every
windowapplication an overkill for this.

AFAIK is VBS is the normal tool for this.

Did you look at the sample in the thread I have showed you?

Cor
 
Sheep Shagger said:
do u know vb??

Sure, I know VB.NET. Even VB.NET supports 'Sub Main' as entry point:

\\\
Public Module Program
Public Sub Main()
DoSomething()
End Sub
End Module
///

.... then choose 'Sub Main' as startup object in the project properties.
 
Back
Top