Solved

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

Posted on 2013-01-27
14
1,405 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
What!!!??? 5 59
VB.Net Outlook.ReportItem Body Text convert to Readable Characters 5 36
MessageBox Appear behind a form in Runtime 1 30
Convert a string to date 4 40
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

739 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