Solved

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

Posted on 2013-01-27
14
1,468 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
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 500 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

617 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