Windows mobile application restart

Posted on 2010-08-25
Medium Priority
Last Modified: 2013-12-21
Hello experts,

Is there any way to restart my windows mobile 6.1 application programmatically? i use vb.net

Question by:spiral2007
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
LVL 18

Expert Comment

by:Dennis Aries
ID: 33518981
Try this
Sub Restart(ByVal program As String)
        For Each proc As Process In Process.GetProcesses
            If proc.ProcessName = program Then proc.Kill()
   End Sub

Expert Comment

ID: 33518988
Take this,

#Region "declares for softreset (KernelIOControl)"

' Control Code flags
Private Const FILE_DEVICE_UNKNOWN As UInteger = &H22
Private Const FILE_DEVICE_HAL As UInteger = &H101
Private Const FILE_DEVICE_CONSOLE As UInteger = &H102
Private Const FILE_DEVICE_PSL As UInteger = &H103
Private Const METHOD_BUFFERED As UInteger = 0
Private Const METHOD_IN_DIRECT As UInteger = 1
Private Const METHOD_OUT_DIRECT As UInteger = 2
Private Const METHOD_NEITHER As UInteger = 3
Private Const FILE_ANY_ACCESS As UInteger = 0
Private Const FILE_READ_ACCESS As UInteger = &H1
Private Const FILE_WRITE_ACCESS As UInteger = &H2

Private Shared Function CTL_CODE(DeviceType As UInteger, [Function] As UInteger, Method As UInteger, Access As UInteger) As UInteger
      Return ((DeviceType << 16) Or (Access << 14) Or ([Function] << 2) Or Method)
End Function

''' <summary>
''' This function provides the kernel with a generic I/O control for
''' carrying out I/O operations.
''' </summary>
''' <param name="dwIoControlCode">I/O control code, which should support the
''' OAL I/O controls. For a list of these I/O controls, see Supported
''' OAL APIs.</param>
''' <param name="lpInBuf">Pointer to the input buffer.</param>
''' <param name="nInBufSize">Size, in bytes, of lpInBuf.</param>
''' <param name="lpOutBuf">Pointer to the output buffer.</param>
''' <param name="nOutBufSize">Maximum number of bytes that can be returned in
''' lpOutBuf.</param>
''' <param name="lpBytesReturned">Address of a DWORD that receives the size,
''' in bytes, of the data returned.</param>
''' <returns>TRUE indicates success; FALSE indicates failure.</returns>
<DllImport("Coredll.dll")> _
Private Shared Function KernelIoControl(dwIoControlCode As UInteger, lpInBuf As IntPtr, nInBufSize As UInteger, lpOutBuf As IntPtr, nOutBufSize As UInteger, ByRef lpBytesReturned As UInteger) As UInteger
End Function
#End Region

''' <summary>
''' the method needed to be called to actually reset the device.
''' </summary>
Public Shared Sub ResetDevice()
      Dim bytesReturned As UInteger = 0
      KernelIoControl(IOCTL_HAL_REBOOT, IntPtr.Zero, 0, IntPtr.Zero, 0, bytesReturned)
End Sub

Expert Comment

ID: 33519013
WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.


Author Comment

ID: 33519085
efatihan i want to restart my application not my device.

djjaries your way is for windows form application ? i use windows mobile 6.1 compact framework

any other suggestions?

Accepted Solution

efatihan earned 2000 total points
ID: 33519152
sorry, i misunderstood your question.
in compact framework, to restart your application you have two choices, one is the following
(i am not sure if it is going to work on wm 6.1)

Public Shared Sub RestartApplication()
      Dim fileName As String = Assembly.GetExecutingAssembly().GetName().CodeBase
      Dim startInfo As New ProcessStartInfo(fileName)
End Sub

the other one is to schedule your application using CeRunAppAtTime to wake up after you close it.
the example is at the following url:

just add few seconds to "now" and let the application start itself.

good luck.

Author Comment

ID: 33520080
hello efatihan i follow the http://www.pinvoke.net/default.aspx/coredll.CeRunAppAtTime
example and it works only if i schedule the wakeup after 10 sec.
is there any way to make this wakeup operation start faster or immediately? (if i change the seconds variable and put a value less than 10sec nothing happens)


Expert Comment

ID: 33520181

this article might help you. i will still continue to look for any remedy.
LVL 24

Expert Comment

ID: 33520401
as the previous link states, the default is 10 seconds for CeRunAtTime() unless it is implemented differently by the vendor.

you might want to consider the dummy console app that just starts your main exe and then exits.

Featured Post

WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

Question has a verified solution.

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

When asking a question in a forum or creating documentation, screenshots are vital tools that can convey a lot more information and save you and your reader a lot of time
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Suggested Courses
Course of the Month11 days, 5 hours left to enroll

770 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