Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to delay service startup? 1

Status
Not open for further replies.

cyberspace

Technical User
Aug 19, 2005
968
GB
Where i work we use Sophos Enterprise anti virus.

This uses a local service account on each PC to download updates from the server, which tends to happen on login.

Also when logging in, the connection manager for our proxy/internet control server starts, and uses the last logged on user to make it "easier"

however, when sophos auto updates, the conenction manager uses the name of the Sophos service account...so does not log in.

Despite being simple to resolve this seems to cause no end of confusion for certain users, no matter how many times they are sorted.

I was thinking that if i could delay the startup on the sophos auto update services, it would resolve the problem.

Im just not sure how to delay this via a script?

Thanks in advance.


'When all else fails.......read the manual'
 
The trick is to add an unecessary service dependency. See MVP Dan Petri's article:
Note: If you have a service that needs to start late in the boot cycle but you do not have a specific service dependency, as explained by Dan Petri above, then choose one of the services which startup last as the data value for the value "Depends on Service". Services commonly selected are Spooler and Messenger.
 
that looks like it could be just what I need.

One thing however - how would i set that on all machines in the domain?

'When all else fails.......read the manual'
 
Create a .reg file and use in your startup script the syntax: regedit /s yourfilename.reg

Here is how to create this file:

Service entries are stored in the registry here:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\your_service

With a subkey of DependOnService

1. Follow Dan Petri's article (above) and make the entries in the Services applet.

2. Start Regedit and export the appropriate services registry entry.

3. Use notepad to clear up any unecessary entries. You only need the lines:

Windows Registry Editor 5.0
<=== blank line here
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\your_service_name
DependOnService="...some sort of entry will be here..."
<=== blank line here
And save the file.

Push this out with the logon script for all users. (It only takes effect after a reboot, and only needs to be run once, although running it more than that will not hurt anything.)

 
Thats great!

I take it i could also make a stand alone login script?

I did this on my own machine and it appears to have done the trick!

I did nothing in the services applet though, i altered the setting directly in the registry. I have exported and tidied it up as you mentioned, and i am left with this:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Sophos AutoUpdate Service]
"DependOnService"=hex(7):72,00,70,00,63,00,73,00,73,00,00,00,53,00,70,00,6f,00,\
6f,00,6c,00,65,00,72,00,00,00,00,00


So i take it that is all i need?


'When all else fails.......read the manual'
 
oh and one last thing sorry, do i need to put the exact path of the .reg file in the script? or do i need to just put the reg file in the "login scripts" folder on the server, along with the script?

'When all else fails.......read the manual'
 
Either path it or place it in the logon folder. Do not forget the regedit /s filename.reg statement.
 
most appreciated!

I will just make a script that simply contains that one line, since not all users run a login script for some reason....

Thanks for your help.

'When all else fails.......read the manual'
 
hmm perhaps i have done something wrong.

when i manually add the dependency, it works just fine.

if i only add the .reg file to startup scripts, and say yes, it works fine.

However, when i use it with the script, it doesnt seem to work, just pulls other garbage through.

All i have in the script is the line:

regedit /s delaysophos.reg

any ideas?

'When all else fails.......read the manual'
 
can i simply add my .reg file, and give it a /s parameter?

'When all else fails.......read the manual'
 
Make sure the logon script ends with the file extension of either .CMD or .BAT
 
hmm that didnt seem to make a difference, the same problem came back that way for some strange reason!

I have just sent the link to the .reg file via email and made sure users have clicked it so that should be fine.

many thanks for your help :)

'When all else fails.......read the manual'
 
I would suggest downloading SLEEP.exe from the windows 2003 resource kit. With that program you can pause a script for a certain duration of time.

Once you download it I would write a script that looks something like this.

Echo Pausing Service Startup
color 9f
@echo off

rem Checking service state
NET START | FIND "SERVICE_NAME" > nul
IF errorlevel 1 GOTO :s_not_running
IF errorlevel 0 GOTO :s_running

:s_running
Rem Stopping the service
NET STOP "SERVICE NAME"

:s_not_running
Rem Pausing 2 minutes
c:\sleep.exe 120
NET START "SERVICE_NAME"

Exit
 
It would be too late. By the time the logon script is processed all services have been started.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top