|
-
Apr 17th, 2003, 09:16 PM
#1
Thread Starter
New Member
VB.NET: How to restart computer after installation process [SOLVED]
Hi, I have a question with VB.NET.
I've developed an application using VB.NET and now I'm trying to make a setup file for its distribution process. I am using the built-in program (MSI) to do the task.
How do I make this setup project restart computer when the main application is installed?
Thanks in advance!
Eric.
Last edited by aspade; Apr 20th, 2003 at 07:59 PM.
What is finite, but boundaryless?
-
Apr 17th, 2003, 09:20 PM
#2
Re: VB.NET: How to restart computer after installation process
Originally posted by aspade
Hi, I have a question with VB.NET.
Then post it in the .Net Forum
-
Apr 17th, 2003, 09:25 PM
#3
Junior Member
use sendkeys to send ctrl-alt-del twice. J/K BTW
-
Apr 17th, 2003, 10:42 PM
#4
I wonder how many charact
Since a class for restarting the computer has not been included in the .Net framework yet... you simply need to call Win32 API's from your .Net applicaton....
do a Google search for Restart Computer in VB6 to get the right API's.... I believe its ExitWindowsEx..... (bear in mind, for XP and 2000, you also need to pass a security parameter, but most of the code I've seen around handles that)...
Then, you need to call the API from your .Net application..just like you would with VB6, just remember Longs in Vb6 are now Integers in VB.Net... so you need to replace any Long returned by a Win32API with Integer...
VB Code:
[u]vb6:[/u]
Private Declare Auto Function MBox Lib "user32.dll" _
Alias "MessageBox" (ByVal hWnd As [b]Long[/b], _
ByVal txt As String, ByVal caption As String, _
ByVal Typ As [b]Long[/b]) As [b]Long[/b]
[u]vb.Net:[/u]
Private Declare Auto Function MBox Lib "user32.dll" _
Alias "MessageBox" (ByVal hWnd As [b]Integer[/b], _
ByVal txt As String, ByVal caption As String, _
ByVal Typ As [b]Integer[/b]) As [b]Integer[/b]
There are also other ways to call Win32API's but the above is the simplest.... for other ways you may refer to this MSDN walkthrough:
http://msdn.microsoft.com/library/de...indowsAPIs.asp
Last edited by nemaroller; Apr 17th, 2003 at 10:46 PM.
-
Apr 20th, 2003, 03:47 PM
#5
Thread Starter
New Member
But...
But I'm trying to implement this "restarting capability" from the setup. Is there any way to do this using the Setup project?
What is finite, but boundaryless?
-
Apr 20th, 2003, 04:21 PM
#6
Sleep mode
Yes , using any of those 3rd party tools that pack your proj (I can't remember right now) .There's an option there to force restarting the machine .
-
Apr 20th, 2003, 04:58 PM
#7
Re: But...
Originally posted by aspade
But I'm trying to implement this "restarting capability" from the setup. Is there any way to do this using the Setup project?
installshield should have this option... you know, if you can "find" it somewhere it's not that expensive
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Apr 20th, 2003, 05:18 PM
#8
Thread Starter
New Member
Re: Re: But...
Originally posted by MrPolite
installshield should have this option... you know, if you can "find" it somewhere it's not that expensive
Well, the problem is that the licensing fee for the InstallShield is somewhere around 2000 bucks!
Hmm.. Would implementing a windows service then sending a "command" to it work? Would that be easier to restart the computer without calling API?
Desperate.
What is finite, but boundaryless?
-
Apr 20th, 2003, 05:36 PM
#9
PowerPoster
Why are you wanting it to restart? Most of the time .Net apps don't require it. I am just wondering why yours does.
-
Apr 20th, 2003, 05:37 PM
#10
Sleep mode
Re: Re: Re: But...
What's the the deal if you used APIs in this case ? It's only 3 to 5 lines of code to restart the machine .
-
Apr 20th, 2003, 05:38 PM
#11
Sleep mode
Maybe he's writing some values to the registry
-
Apr 20th, 2003, 05:51 PM
#12
Thread Starter
New Member
B/C
Originally posted by hellswraith
Why are you wanting it to restart? Most of the time .Net apps don't require it. I am just wondering why yours does.
Because I'm writing a software that needs to be started right away when it's installed. Unless I restart the computer, I don't see how I can achieve this.
Even with the windows service, how do I start it right away after the installation?
If I can somehow start it, then the need to restart the computer is no longer a problem.
Help?
What is finite, but boundaryless?
-
Apr 20th, 2003, 05:51 PM
#13
Sleep mode
-
Apr 20th, 2003, 05:56 PM
#14
Sleep mode
Best bet in this case is to write in the reg startup key your app name to start after restarting . (in some package maker you can write script and the installer itself will write that in the reg ) .
-
Apr 20th, 2003, 05:57 PM
#15
Thread Starter
New Member
Yeah, that's exactly what I did. I wrote it on the Registry so that it starts automatically when the computer is rebooted. But that's not enough. If I don't find a way to force restart, then it's useless. I'm working in an environment where rebooting occurs once every while.. Maybe once a month, if I'm lucky. I need to restart the comp..
What is finite, but boundaryless?
-
Apr 20th, 2003, 06:13 PM
#16
Sleep mode
Originally posted by aspade
Yeah, that's exactly what I did. I wrote it on the Registry so that it starts automatically when the computer is rebooted. But that's not enough. If I don't find a way to force restart, then it's useless. I'm working in an environment where rebooting occurs once every while.. Maybe once a month, if I'm lucky. I need to restart the comp..
I can't think of any other options right now . Just try out any of the above links ,to see if they help !
-
Apr 20th, 2003, 06:51 PM
#17
Fanatic Member
Because I'm writing a software that needs to be started right away when it's installed. Unless I restart the computer, I don't see how I can achieve this.
Even with the windows service, how do I start it right away after the installation?
Actually it seems to me that if you just want to start an app (especially a service) then restarting the computer is not a great way to get it done. If you want to start an installed service, check out the ServiceController component:
ms-help://MS.VSCC/MS.MSDNVS/vbcon/html/vbconintroductiontoservicecontrollercomponent.htm
ms-help://MS.VSCC/MS.MSDNVS/vbcon/html/vbtskperformingadministrativetasksonservices.htm
If you want to start an executable in interactive mode, you might use the Shell function:
ms-help://MS.VSCC/MS.MSDNVS/vblr7/html/vafctShell.htm
Restarting the computer just because you want to start an app seems like a backwards way to do it?
-
Apr 20th, 2003, 06:57 PM
#18
PowerPoster
Umm why not just let whoever installed it start it? Why does the installation package need to start it? Makes no sense.
-We have enough youth. How about a fountain of "Smart"?
-If you can read this, thank a teacher....and since it's in English, thank a soldier.

-
Apr 20th, 2003, 08:02 PM
#19
Thread Starter
New Member
Thanks to everyone who tried to help me. But I found a way around the problem.
I wrote a short project that makes an instance of a service controller for my service which then calls my service to launch. Then this little .exe file is added to the setup project's custom actions and set it to laucnh when the installation is completed.
So this is it. The service starts as soon as the installation is done.
Thanks all!
What is finite, but boundaryless?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|