Windows 10: Bat or Exe file to restart Computer Browser Service

Discus and support Bat or Exe file to restart Computer Browser Service in Windows 10 Support to solve the problem; About 1 out of every 6 times I turn my laptop on I have to restart the computer browser service to be able to connect to networks. Is there a bat or... Discussion in 'Windows 10 Support' started by craigg, Mar 19, 2017.

  1. craigg Win User

    Bat or Exe file to restart Computer Browser Service


    About 1 out of every 6 times I turn my laptop on I have to restart the computer browser service to be able to connect to networks. Is there a bat or exe file I can create that I can just click on and run to restart the service instead of having to go into the services/computer browser area to restart each time this happens? Thanks.

    :)
     
    craigg, Mar 19, 2017
    #1

  2. Bat or Exe file to restart Computer Browser Service

    Please remember to mark my reply as "Answer" to this thread.
     
    Frederik Long, Mar 19, 2017
    #2
  3. Bat or Exe file to restart Computer Browser Service

    You can create a desktop or task bar shortcut using this command line:

    net start "Computer Browser"


    Bat  or Exe file to restart Computer Browser Service [​IMG]


    You must then right-click the short-cut, left-click "Properties", "Shortcut", "Advanced" and tick "Run as Administrator".
     
    Frederik Long, Mar 19, 2017
    #3
  4. Pyprohly Win User

    Bat or Exe file to restart Computer Browser Service

    You should really get to the root of the problem, but since this is a good opportunity to brush up on my scripting I’m going to assume you’ve verified the service’s settings are regular and that you’ve exhausted your options, so here are your suggestions in fruition.

    Batch (.bat)
    Code: @echo off set "service=MyServiceName" >nul sc query "%SERVICE:"=%" if errorlevel 1 ( if errorlevel 1060 ( >&2 echo Cannot find any service with service name '"%SERVICE:"=%"' ) else ( >&2 echo Error ) exit /b 1 ) sc query "%SERVICE:"=%" | find "STATE" | findstr "2 4" >nul if errorlevel 1 ( >nul sc start "%SERVICE:"=%" if errorlevel 1 ( >&2 echo Error starting service exit /b 1 ) ) else ( >nul sc stop "%SERVICE:"=%" if errorlevel 1 ( >&2 echo Error stopping service exit /b 1 ) >nul pathping -n -p 220 -q 1 127.0.0.1 >nul sc start "%SERVICE:"=%" )[/quote]
    C# (.exe)
    PHP Code: using System;
    using System.Windows.Forms;
    using System.ServiceProcess;

    class Program
    {
    static void Main(string[] args)
    {
    ServiceController service = new ServiceController("MyServiceName");

    if ((service.Status & (ServiceControllerStatus.Running | ServiceControllerStatus.StartPending)) == 0)
    {
    try
    {
    service.Start();
    }
    catch (Exception e)
    {
    MessageBox.Show(e.Message);
    }
    }
    else
    {
    try
    {
    service.Stop();
    service.WaitForStatus(ServiceControllerStatus.Stopped);
    service.Start();
    }
    catch (Exception e)
    {
    MessageBox.Show(e.Message);
    }
    }
    }
    }

    VBScript (.vbs)
    Code: strService = "MyServiceName" Set objSWbemServices = GetObject("winmgmts:\\.\root\cimv2") Set colServices = objSWbemServices.ExecQuery("SELECT * FROM Win32_Service WHERE Name = '" & strService & "'") If colServices.Count = 0 Then WScript.Echo "Cannot find any service with service name '" & strService & "'" End If On Error Resume Next For Each svc In colServices If svc.State = "Running" Or svc.State = "Start Pending" Then result = svc.StopService If result <> 0 Then If result = 2 Then WScript.Echo "Error stopping service: Access is denied" WScript.Quit 1 End If WScript.Echo "Error stopping service: " & Err.Description WScript.Quit 1 End If WScript.Sleep 200 svc.StartService Else svc.StartService If result <> 0 Then WScript.Echo "Error starting service: " & Err.Description WScript.Quit 1 End If End If Next[/quote]
    You should replace ‘MyServiceName’ with the name of your service (not to be confused with the service display name, e.g., ‘w32time’ instead of ‘Windows Time’).

    Many services can be started but cannot be stopped without administrative privileges. If you know or suspect this is the case with your service, you may need to run the program as administrator each time.
     
    Pyprohly, Mar 20, 2017
    #4
Thema:

Bat or Exe file to restart Computer Browser Service

Loading...
  1. Bat or Exe file to restart Computer Browser Service - Similar Threads - Bat Exe file

  2. Bat file

    in Windows 10 Gaming
    Bat file: I have a bat fileI am improving it bit by bit till I have reached But not i have added a warning to it before a commandI now want to make that line font size Bigger than the others How can I do that ??So here is the Batch file content@ECHO OFF echo...
  3. Files Detected as Malware after comiling with bat-to-exe compilers

    in AntiVirus, Firewalls and System Security
    Files Detected as Malware after comiling with bat-to-exe compilers: hi, i made batch files, i used many types of BATCH-to-exe compiler. but after compiling them, Windows Defender detects them as Threats/Malwares/Trojans . is it problem with the app or is it false positive?...
  4. Bat file

    in Windows 10 Ask Insider
    Bat file: Good morning/evening/night, I wanted to create a batch file or an exe that can change options inside the gui of an application (the application is cisco webex) (if you are familliar with webex i want to change the audio or turn it to music mode witha batch file) but i am...
  5. .bat file to restart explorer.exe sometimes fail

    in Windows 10 Support
    .bat file to restart explorer.exe sometimes fail: I have a .bat file with this line of code only without quotation. "taskkill /F /IM explorer.exe & start explorer" problem is 50% of time it will work as intended, but other 50% it simply does not start explorer once task is killed. what is causing this and how can I change...
  6. Convert Bat to exe?

    in Windows 10 Software and Apps
    Convert Bat to exe?: Is there a way to convert a batch file to exe but it is not detected as a trojan? Bat zu exe konvertieren?
  7. Cannot run an .exe file from .bat file in windows server 2016

    in Windows 10 Customization
    Cannot run an .exe file from .bat file in windows server 2016: I can not run .exe file from a .bat file, .bat file is dynamically create file which contains path to the .exe file. I can see the log of .bat file it prints echo statements but when It comes to execute .exe file it just skip. when I run .exe file manually it runs perfectly....
  8. How to find out the list of commands for a .bat or .exe file?

    in Windows 10 Customization
    How to find out the list of commands for a .bat or .exe file?: hard to describe what im looking for i'll do my best to explain in details. example, an image software I use photo.exe when installed it automatically set up shell in registry for windows context menu for files type .bmp/.jpg etc etc. when viewed in registry/shell it show...
  9. Create exe files from bat files using native windows commands

    in Windows 10 Software and Apps
    Create exe files from bat files using native windows commands: Came across this hidden Windows gem I have never seen about converting bat to exe files. I know there are 3rd party apps but was unaware you could do it from Windows iExpress: Convert BAT-files into EXE-files [How-To] | Maintenance and System Tools | Windows Tools, Help...
  10. Not able to launch certain .exe files with created .bat shortcuts

    in Windows 10 Support
    Not able to launch certain .exe files with created .bat shortcuts: Hello, To be able to use custom tiles on the Start Menu, I make .bat files of .exe files to use them as shortcuts to launch the .exe files. I make the .bat file by opening Notepad, pasting the directory path of the .exe file in quotes, and then save it as a .bat file. This...

Users found this page by searching for:

  1. how to restart browser with bat