Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Restart windows and resume application process after restarting from VB.Net

Posted on 2013-01-27
14
Medium Priority
?
1,547 Views
Last Modified: 2013-01-27
Hi Experts,

I have written an application with VB.Net. I need, whenever user click one of  my application button, PC will restart and windows will start my application at the startup and the remaining process from my application will resume.

How to do this from VB.Net for Windows XP & 7?

Kindly help,

Regards,
Soumen
0
Comment
Question by:Soumen-Roy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 6
14 Comments
 
LVL 42

Expert Comment

by:sedgwick
ID: 38824081
Startup folder location:

win7 -
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup

winxp -
C:\Documents and Settings\All Users\Start Menu\Programs\Startup

in your vb.net exe, in the 1st phase before reboot, create a batch script and place it in the above location depends on the OS.

the script should contain the full path of your vb.net exe and pass an argument the app which will indicate running from startup.

for example:

c:\files\myapp.exe "startup"

in your app, check for this argument in Main function, and continue the remaining process of the application.
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 38824084
0
 

Author Comment

by:Soumen-Roy
ID: 38824091
@sedgwick,

Wow !!! Just as I expected. One little query, may I prevent user to do anything after the restart and until the process ends?

Actually if I run my process right after the boot menu and then windows opens / initialize, my target will be achieved. Is it possible?

Regards,
Soumen
0
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 
LVL 42

Expert Comment

by:sedgwick
ID: 38824095
how long should take the 2nd part of the processing in your app?
0
 

Author Comment

by:Soumen-Roy
ID: 38824125
may be 40 mins to 1 hour. it is a back up process of entire system volume. but if user changes between the back up process, problem will arise. thats why i want to prevent user to do anything at time of the process running. Is it possible?
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 38824139
you can disable mouse and keyboard but i think splash screen with message "Back up process, do not touch", would be enough:

Splash Screen VB.NET
0
 

Author Comment

by:Soumen-Roy
ID: 38824188
Done, if mouse & keyboard can be disabled then my job is over. But how to disable those two?
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 38824210
the fastest way of doing this is to download autoit from:
AutoIt

and run the following to disable mouse & keyboard:
BlockInput(1);

to enable mouse & keyboard:
BlockInput(0);
0
 

Author Comment

by:Soumen-Roy
ID: 38824278
I downloaded that, seems very interesting, but can't understand how to integrate with my VB.Net code. Can any dll to be referenced? Any light on that, please?
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 38824298
you can either create 2 autoit scripts:
one with the line: BlockInput(1);
and the other with the line: BlockInput(0);

or convert your autoit script to exe and allow to accept parameter (disable/enable)
and inside the autoit exe check the parameter to call BlockInput with 1 or 0.

in your vb.net exe after reboot, you run the exe/script with the right parameter to block user input, and after backup process is done you run it again with the enable parameter.
0
 

Author Comment

by:Soumen-Roy
ID: 38824309
oO, give me some time to learn how to create autoit script, please, i have no idea regarding this

:-(
0
 
LVL 42

Accepted Solution

by:
sedgwick earned 2000 total points
ID: 38824319
i created the script for you, save it as user_input.au3 file.


;check if param is available
If $CmdLine[0] = 0 Then Exit (1)

;if "disable", then disable mouse+keyboard
if $CmdLine[1] = "disable" then
	BlockInput(1)
else
	;check if "enable", then enable mouse+keyboard
	if $CmdLine[1] = "enable" then
		BlockInput(0)
	EndIf
EndIf

Open in new window


compile the script to exe and run it from your vb.net code:
to disable user input:
Process.Start("user_input.exe", "disable")

Open in new window


to enable user input:
Process.Start("user_input.exe", "enable")

Open in new window

0
 

Author Closing Comment

by:Soumen-Roy
ID: 38824333
You guys are always proven as god to me :-).

Thanx :-)
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 38824338
you welcome, good luck :)
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question