Home All Groups Group Topic Archive Search About

Startup a winform hidden

Author
20 Feb 2006 4:36 PM
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

Author
20 Feb 2006 4:46 PM
Marwan Tarek
Hello Alison,

why don't make it a windows service

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


Show quoteHide quote
> 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
Author
20 Feb 2006 4:51 PM
Josef Brunner
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

Show quoteHide quote
"Alison Givens" <i***@cross-it.nl> schrieb im Newsbeitrag
news:uHpLVvjNGHA.916@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
>
>
>
Author
20 Feb 2006 4:59 PM
Alison Givens
How do I do that?
Please give me a code example.




Show quoteHide quote
"Josef Brunner" <joey@newsgroups.nospam> wrote in message
news:eZd7c3jNGHA.428@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" <i***@cross-it.nl> schrieb im Newsbeitrag
> news:uHpLVvjNGHA.916@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
>>
>>
>>
>
>
Author
20 Feb 2006 5:08 PM
Josef Brunner
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





Show quoteHide quote
"Alison Givens" <i***@cross-it.nl> schrieb im Newsbeitrag
news:efoaP8jNGHA.3936@TK2MSFTNGP10.phx.gbl...
> How do I do that?
> Please give me a code example.
>
>
>
>
> "Josef Brunner" <joey@newsgroups.nospam> wrote in message
> news:eZd7c3jNGHA.428@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" <i***@cross-it.nl> schrieb im Newsbeitrag
>> news:uHpLVvjNGHA.916@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
>>>
>>>
>>>
>>
>>
>
>
Author
20 Feb 2006 8:29 PM
Herfried K. Wagner [MVP]
"Alison Givens" <i***@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/>
Author
21 Feb 2006 3:48 AM
Sheep Shagger
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

Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
news:%23JLTAxlNGHA.3888@TK2MSFTNGP12.phx.gbl...
> "Alison Givens" <i***@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/>
>
Author
21 Feb 2006 7:45 AM
Cor Ligthert [MVP]
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
Author
21 Feb 2006 8:42 AM
Alison Givens
Can somebody please help me out with my question, since that is the purpose
of the newsgroup....lol




Show quoteHide quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
news:%23Nr1hqrNGHA.984@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
>
Author
21 Feb 2006 8:52 AM
Alison Givens
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






Show quoteHide quote
"Alison Givens" <i***@cross-it.nl> wrote in message
news:eIO3$KsNGHA.3788@TK2MSFTNGP09.phx.gbl...
>
> Can somebody please help me out with my question, since that is the
> purpose of the newsgroup....lol
>
>
>
>
> "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
> news:%23Nr1hqrNGHA.984@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
>>
>
>
Author
21 Feb 2006 9:34 AM
Cor Ligthert [MVP]
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


Show quoteHide quote
"Alison Givens" <i***@cross-it.nl> schreef in bericht
news:edkSVQsNGHA.3276@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" <i***@cross-it.nl> wrote in message
> news:eIO3$KsNGHA.3788@TK2MSFTNGP09.phx.gbl...
>>
>> Can somebody please help me out with my question, since that is the
>> purpose of the newsgroup....lol
>>
>>
>>
>>
>> "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
>> news:%23Nr1hqrNGHA.984@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
>>>
>>
>>
>
>
Author
21 Feb 2006 9:48 AM
Alison Givens
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



Show quoteHide quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
news:u3P0OnsNGHA.3984@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" <i***@cross-it.nl> schreef in bericht
> news:edkSVQsNGHA.3276@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" <i***@cross-it.nl> wrote in message
>> news:eIO3$KsNGHA.3788@TK2MSFTNGP09.phx.gbl...
>>>
>>> Can somebody please help me out with my question, since that is the
>>> purpose of the newsgroup....lol
>>>
>>>
>>>
>>>
>>> "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
>>> news:%23Nr1hqrNGHA.984@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
>>>>
>>>
>>>
>>
>>
>
>
Author
21 Feb 2006 10:22 AM
Cor Ligthert [MVP]
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/microsoft.public.windowsxp.customize/browse_frm/thread/524c1ea67cc96892/fa0df0bbfad969cf?lnk=st&q=alert+vbs+user+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
Author
21 Feb 2006 10:33 AM
Alison Givens
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



Show quoteHide quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
news:%237$o1BtNGHA.2012@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/microsoft.public.windowsxp.customize/browse_frm/thread/524c1ea67cc96892/fa0df0bbfad969cf?lnk=st&q=alert+vbs+user+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
>
Author
21 Feb 2006 11:04 AM
Cor Ligthert [MVP]
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
Author
21 Feb 2006 1:55 PM
C-Services Holland b.v.
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
Author
21 Feb 2006 1:54 PM
Alison Givens
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.





Show quoteHide quote
"C-Services Holland b.v." <c**@REMOVEcsh4u.nl> wrote in message
news:1Mudnbg5WN1whGbeRVnytQ@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
Author
21 Feb 2006 2:40 PM
Phill W.
"Alison Givens" <i***@cross-it.nl> wrote in message
news:uTgsCwsNGHA.3360@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.
Author
21 Feb 2006 9:30 AM
Cor Ligthert [MVP]
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
Author
21 Feb 2006 9:50 AM
Alison Givens
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.




Show quoteHide quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
news:esdq5ksNGHA.2036@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
>
Author
21 Feb 2006 10:06 AM
Cor Ligthert [MVP]
> 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
Author
21 Feb 2006 10:08 AM
Alison Givens
Yes I noticed, but my message was sent allready.
He was called Mrs Wagner, not sheep shagger.


Show quoteHide quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
news:er7h54sNGHA.428@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
>
Author
21 Feb 2006 11:33 AM
Herfried K. Wagner [MVP]
"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/>