I need to stop and restart the Windows Search service on a laptop running Windows 10, so that it will index a disk drive that isn't present at boot time.
I can do this manually from the Services applet, by right clicking and choosing restart.
I tried a BAT file that simply has
NET STOP WSearch
NET START WSearch
(with a ping in between to add a bit of a delay).
This doesn't seem to work properly. Sometimes it says that it can't stop the service. Other times the stop seems to work, but the start says the service is already running.
The service startup is set to "Automatic (Delayed Start)", and this would be perfect if I could change the delay time, but I have no idea how to do that.
Any suggestions on the best way to proceed?
BAT file to restart WSearch service
-
- Administrator
- Posts: 12629
- Joined: 16 Jan 2010, 15:49
- Location: London, Europe
-
- gamma jay
- Posts: 25455
- Joined: 17 Mar 2010, 17:33
- Location: Cape Town
Re: BAT file to restart WSearch service
Only a suggestion (based on a find to disable and enable (in stead of stop and start).
Whether this is helpful of not, or gives you a pointer to a solution, I dunno...but see here...
Addition:
...or here for comprehensive info (Win10 not mentioned though).
Whether this is helpful of not, or gives you a pointer to a solution, I dunno...but see here...
Addition:
...or here for comprehensive info (Win10 not mentioned though).
Regards,
Rudi
If your absence does not affect them, your presence didn't matter.
Rudi
If your absence does not affect them, your presence didn't matter.
-
- Administrator
- Posts: 7218
- Joined: 15 Jan 2010, 22:52
- Location: Middle of England
Re: BAT file to restart WSearch service
Anything here of use: Set Delay time for Startup programs in Windows 10/8/7?
Or here: Adjusting the Autostart (Delayed) start time?
Or here: Adjusting the Autostart (Delayed) start time?
Leif
-
- Administrator
- Posts: 12629
- Joined: 16 Jan 2010, 15:49
- Location: London, Europe
Re: BAT file to restart WSearch service
I should have just tried it.
When I ran the BAT file manually it gave the results I said. I just added it to task scheduler and it seems to be working fine. Life is strange.
When I ran the BAT file manually it gave the results I said. I just added it to task scheduler and it seems to be working fine. Life is strange.
StuartR
-
- gamma jay
- Posts: 25455
- Joined: 17 Mar 2010, 17:33
- Location: Cape Town
Re: BAT file to restart WSearch service
Now you can REALLY claim all the credit!
Regards,
Rudi
If your absence does not affect them, your presence didn't matter.
Rudi
If your absence does not affect them, your presence didn't matter.
-
- Administrator
- Posts: 12629
- Joined: 16 Jan 2010, 15:49
- Location: London, Europe
-
- PlatinumLounger
- Posts: 5420
- Joined: 24 Jan 2010, 08:33
- Location: A cathedral city in England
Re: BAT file to restart WSearch service
Possibly due to a difference in the accounts and/or privileges under which this ran?StuartR wrote:When I ran the BAT file manually it gave the results I said. I just added it to task scheduler and it seems to be working fine. Life is strange.
John Gray
"(or one of the team)" - how your hospital appointment letter indicates that you won't be seeing the Consultant...
"(or one of the team)" - how your hospital appointment letter indicates that you won't be seeing the Consultant...
-
- Administrator
- Posts: 12629
- Joined: 16 Jan 2010, 15:49
- Location: London, Europe
Re: BAT file to restart WSearch service
I was running the BAT file as Administrator. I suspect it is to do with the Autorestart feature in the Windows service manager. I have a feeling that the service doesn't really need to be restarted because Windows does that automatically when you stop it with Net Stop. This could also account for the command thinking it has failed, as it sees the service is still running.
StuartR
-
- PlatinumLounger
- Posts: 5420
- Joined: 24 Jan 2010, 08:33
- Location: A cathedral city in England
Re: BAT file to restart WSearch service
Maybe investigating some of the SC options (like SC STOP <servicename> then SC QUERY <servicename>) would assist in debugging? [Check the syntax!]
NET STOP/START is a bit of a do-it-and-hope method in comparison...
NET STOP/START is a bit of a do-it-and-hope method in comparison...
John Gray
"(or one of the team)" - how your hospital appointment letter indicates that you won't be seeing the Consultant...
"(or one of the team)" - how your hospital appointment letter indicates that you won't be seeing the Consultant...
-
- Administrator
- Posts: 12629
- Joined: 16 Jan 2010, 15:49
- Location: London, Europe
-
- Administrator
- Posts: 12629
- Joined: 16 Jan 2010, 15:49
- Location: London, Europe
Re: BAT file to restart WSearch service
That was informative John. After SC stop Wsearch, I tried SC query WSearch very quickly a few times and the status was STOP PENDING for a very short time and then START PENDING and then RUNNING, which confirms my suspicion that it was auto-restarting very quickly
StuartR
-
- PlatinumLounger
- Posts: 5420
- Joined: 24 Jan 2010, 08:33
- Location: A cathedral city in England
Re: BAT file to restart WSearch service
SC can be very useful, but in BATch files one has to deal with the complicated output.
Glad it has brought enlightenment!
Glad it has brought enlightenment!
John Gray
"(or one of the team)" - how your hospital appointment letter indicates that you won't be seeing the Consultant...
"(or one of the team)" - how your hospital appointment letter indicates that you won't be seeing the Consultant...
-
- Administrator
- Posts: 12629
- Joined: 16 Jan 2010, 15:49
- Location: London, Europe
Re: BAT file to restart WSearch service
In any case, I am a happy bunny because I can now index this transient disk drive.
StuartR