473,382 Members | 1,390 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Startup a winform hidden

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

Feb 20 '06 #1
22 3373
Hello Alison,

why don't make it a windows service

Marwan Tarek
http://www.sharepointblogs.com/marwantarek/

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

Feb 20 '06 #2
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

"Alison Givens" <in**@cross-it.nl> schrieb im Newsbeitrag
news:uH*************@TK2MSFTNGP10.phx.gbl...
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

Feb 20 '06 #3
How do I do that?
Please give me a code example.


"Josef Brunner" <jo**@newsgroups.nospam> wrote in message
news:eZ*************@tk2msftngp13.phx.gbl...
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

"Alison Givens" <in**@cross-it.nl> schrieb im Newsbeitrag
news:uH*************@TK2MSFTNGP10.phx.gbl...
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


Feb 20 '06 #4
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" <in**@cross-it.nl> schrieb im Newsbeitrag
news:ef**************@TK2MSFTNGP10.phx.gbl...
How do I do that?
Please give me a code example.


"Josef Brunner" <jo**@newsgroups.nospam> wrote in message
news:eZ*************@tk2msftngp13.phx.gbl...
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

"Alison Givens" <in**@cross-it.nl> schrieb im Newsbeitrag
news:uH*************@TK2MSFTNGP10.phx.gbl...
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



Feb 20 '06 #5
"Alison Givens" <in**@cross-it.nl> schrieb:
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'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Feb 20 '06 #6
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

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
"Alison Givens" <in**@cross-it.nl> schrieb:
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'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Feb 21 '06 #7
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
Feb 21 '06 #8

Can somebody please help me out with my question, since that is the purpose
of the newsgroup....lol


"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
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

Feb 21 '06 #9
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 Givens" <in**@cross-it.nl> wrote in message
news:eI**************@TK2MSFTNGP09.phx.gbl...

Can somebody please help me out with my question, since that is the
purpose of the newsgroup....lol


"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
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


Feb 21 '06 #10
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
Feb 21 '06 #11
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
"Alison Givens" <in**@cross-it.nl> schreef in bericht
news:ed**************@TK2MSFTNGP09.phx.gbl...
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 Givens" <in**@cross-it.nl> wrote in message
news:eI**************@TK2MSFTNGP09.phx.gbl...

Can somebody please help me out with my question, since that is the
purpose of the newsgroup....lol


"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
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



Feb 21 '06 #12
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

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:u3**************@TK2MSFTNGP14.phx.gbl...
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
"Alison Givens" <in**@cross-it.nl> schreef in bericht
news:ed**************@TK2MSFTNGP09.phx.gbl...
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 Givens" <in**@cross-it.nl> wrote in message
news:eI**************@TK2MSFTNGP09.phx.gbl...

Can somebody please help me out with my question, since that is the
purpose of the newsgroup....lol


"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
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



Feb 21 '06 #13
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.


"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:es**************@TK2MSFTNGP14.phx.gbl...
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

Feb 21 '06 #14
> 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
Feb 21 '06 #15
Yes I noticed, but my message was sent allready.
He was called Mrs Wagner, not sheep shagger.
"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:er*************@tk2msftngp13.phx.gbl...
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

Feb 21 '06 #16
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/micro...0df0bbfad969cf

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
Feb 21 '06 #17
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

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
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/micro...0df0bbfad969cf

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

Feb 21 '06 #18
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
Feb 21 '06 #19
"Sheep Shagger" <sh***@shagger.net> schrieb:
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.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Feb 21 '06 #20
Alison Givens wrote:
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.


So basically you're writing a program because people refuse the obey the
company rules (only save to the network). So you're going to call
copy.bat. What is that going to copy? The whole disk? You'll need to
since you obviously don't have control over where people save their
data. If you're only copying certain directories, you're bound to miss
some files.

The users need to be educated and learn that the only safe way to store
their files is on the network. Educational manners (for sysops): clear
the HD from time to time (first backup the files) and let them sweat it
out a few hours before returning their files. In my experience users
learn pretty quick to use the network that way >:)

Maybe print out the text:

"FILES ON LOCAL DRIVES AREN'T INCLUDED IN THE BACKUP"

on a sheet of A0 paper and hang that in the office for a while. Or
better yet, make it a windows wallpaper and enforce it using policies so
they can't change the wallpaper.

While these measures seem rediculous, my point is that you need to
educate your users and not let them make you clean up their mess.

--
Rinze van Huizen
C-Services Holland b.v
Feb 21 '06 #21
We are fully aware of this.
It is just that we have clients that use Terminal Server.
We have certain programs that we don't like to use through Terminal Server.
Therefore these programs run locally.

"C-Services Holland b.v." <cs*@REMOVEcsh4u.nl> wrote in message
news:1M********************@zeelandnet.nl...
Alison Givens wrote:
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.


So basically you're writing a program because people refuse the obey the
company rules (only save to the network). So you're going to call
copy.bat. What is that going to copy? The whole disk? You'll need to since
you obviously don't have control over where people save their data. If
you're only copying certain directories, you're bound to miss some files.

The users need to be educated and learn that the only safe way to store
their files is on the network. Educational manners (for sysops): clear the
HD from time to time (first backup the files) and let them sweat it out a
few hours before returning their files. In my experience users learn
pretty quick to use the network that way >:)

Maybe print out the text:

"FILES ON LOCAL DRIVES AREN'T INCLUDED IN THE BACKUP"

on a sheet of A0 paper and hang that in the office for a while. Or better
yet, make it a windows wallpaper and enforce it using policies so they
can't change the wallpaper.

While these measures seem rediculous, my point is that you need to educate
your users and not let them make you clean up their mess.

--
Rinze van Huizen
C-Services Holland b.v

Feb 21 '06 #22

"Alison Givens" <in**@cross-it.nl> wrote in message
news:uT**************@TK2MSFTNGP15.phx.gbl...
In the netwerk environment, there still are users that place some of their
files on the local disk.
Aren't there always ... ;-)
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.


And therein lies your biggest problem.
When windows tries to shut down, it asks each running process,
/including/ the one that you've just /started/ to do all this file copying,
to shut down "nicely". It the process fails to do so - and yours obviously
will, because it's busy - Windows pops up a dialog asking if the user wants
to wait for the process to finish or just kill it off and, if they choose to
kill it,
there's absolutely nothing you can do about it.

Have you considered kicking this process off at the /start/ of the day, when
they start up their PC? I'd suggest this is a far safer proposition
(although,
of course, it may not marry up with your server backup schedule).

Regards,
Phill W.
Feb 21 '06 #23

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: D Witherspoon | last post by:
An application I've just finished developing is not showing up in the taskbar on startup until the application is clicked on. This makes it difficult as it is being launched as a No Touch...
0
by: someone | last post by:
Hi, We are encountering a problem with the DTPicker. This is the situation: We have a DTPicker-control on a VB6 Active-X. The Active-X is used on a .NET winform. the problem: The .Net...
2
by: Mark | last post by:
Hi All, Is there a way that I can set the startup form to be invisible? Many thanks, Mark
7
by: cefrancke | last post by:
I cant seem to find a straight answer on the following. I want to programmatically hide all menus except a basic custom report menu (during report preview) and right click pop-up A-Z sorting on...
2
by: Tom | last post by:
Hi all In winform application I am trying to start 2 forms I am trying to show the 2nd winform on a separate thread. using Thread mainapp = new Thread(new ThreadStart(loadmainscm)); ...
5
by: Scott | last post by:
Hi everyone, I have a c# console app that when run through an autorun.inf file, launches a web page from the CD. It works just fine but I would like the console window minimized on startup....
8
by: cj | last post by:
In 2003 I sometimes changed the startup object of a project to Sub Main which was found in Module1.vb. I upgraded one such project to 2005 and I notice in the properties page for the project that...
0
by: dadizhu | last post by:
Hi, everyone. I ran into an UI freeze issue with threading and simplied the problem down to the following sample code. The logic is as follows: 1. The main UI thread creates a non-UI STA...
4
by: Jeff Ciaccio | last post by:
I'm new to vb.net and was wondering what the syntax is for application events such as starting up or shutting down. For example, if you would just like to get a user's name with an input box when...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.