Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/15/2014 in all areas

  1. I were in the same problem of you and I've developed time ago a mini-tool in .NET (VB) to solve that issue. You can compile this Class into an exe and just run the compiled exe, the entire desktop is shown not only a explorer window like happened using CMD. But my program is not for restart explorer, it don't kills explorer, it just start it, so if you want to kill explorer then you need to write that isntruction (in Batch for example using TaskKill command like you was using in your example). PS: If you want the program compiled then here is: http://www.mediafire.com/download/olj659v29ao8gdv/InitializeExplorer.exe The source is just a CLI app with a Module containning these lines: ' By Elektro #Region " Imports " Imports System.IO Imports System.Runtime.InteropServices Imports InitializeExplorer.NativeMethods #End Region ''' ''' Initializes a new instance of Explorer process. ''' Module InitializeExplorer #Region " P/Invoke " ''' ''' Class NativeMethods. ''' Friend Class NativeMethods ''' ''' Retrieves a handle to the top-level window whose class name and window name match the specified strings. ''' This function does not search child windows. ''' This function does not perform a case-sensitive search. ''' ''' ''' The class name or a class atom created by a previous call to the ''' RegisterClass or RegisterClassEx function. ''' The atom must be in the low-order word of lpClassName; ''' the high-order word must be zero. ''' If lpClassName points to a string, it specifies the window class name. ''' The class name can be any name registered with RegisterClass or RegisterClassEx, ''' or any of the predefined control-class names. ''' If lpClassName is NULL, it finds any window whose title matches the lpWindowName parameter. ''' ''' ''' The window name (the window's title). ''' If this parameter is NULL, all window names match. ''' IntPtr. Public Shared Function FindWindowByClass( ByVal lpClassName As String, ByVal zero As IntPtr ) As IntPtr End Function End Class #End Region #Region " ReadOnly Strings " ''' ''' Indicates the directory where the Explorer process is located. ''' Private ReadOnly ExplorerDirectory As String = Environment.GetFolderPath(Environment.SpecialFolder.Windows) ''' ''' Indicates the filename of the process. ''' Private ReadOnly ExplorerFilename As String = "Explorer.exe" ''' ''' Indicates the desk Taskbar Class-name. ''' Private ReadOnly TaskBarClassName As String = "Shell_TrayWnd" #End Region #Region " Process " ''' ''' The explorer process. ''' Dim Explorer As New Process With { .StartInfo = New ProcessStartInfo With { .FileName = Path.Combine(ExplorerDirectory, ExplorerFilename), .WorkingDirectory = My.Application.Info.DirectoryPath, .UseShellExecute = True, .CreateNoWindow = True } } #End Region #Region " Main " ''' ''' Defines the entry point of the application. ''' Sub Main() Select Case Convert.ToBoolean(CInt(FindWindowByClass(TaskBarClassName, Nothing))) Case False ' The Taskbar is not found. Try Explorer.Start() Console.WriteLine("Windows Explorer has been re-initialized successfully") Environment.Exit(0) Catch ex As Exception Console.WriteLine(ex.Message) Debug.WriteLine(ex.Message) Environment.Exit(1) End Try Case True ' The Taskbar is found. Console.WriteLine("Can't proceed, Windows Explorer is currently running. Exiting...") Environment.Exit(2) End Select End Sub #End Region End Module
    1 point
×
×
  • Create New...