cyber_killer Posted December 29, 2008 Posted December 29, 2008 Hi, i need script which will do stop service if the computer is in domain, if not than service should be started.
Yzöwl Posted December 29, 2008 Posted December 29, 2008 More information is required, if you want help you must be willing to provide sufficient information for us to work with!
cyber_killer Posted December 29, 2008 Author Posted December 29, 2008 I have few laptops on where is installed firewal. This firewal is runnig as service. So i need to deploy script via GPO, which will stop the service, when laptop is in the domain, when laptop is out from our domain then the service must be running.I was thinking in this style. Ping domain DC if success then stop the service, if not start the service.Plese let me know if this is enough information.
Yzöwl Posted December 29, 2008 Posted December 29, 2008 Here's a quick idea using a Windows NT Command Script: this is most likely English Language dependant@Echo off&Setlocal enableextensions(Set FW=ServiceName.ext)For /f "tokens=3*" %%a In ( 'Net Config Work^|Findstr/ib /c:"Full Computer Name" /c:"Logon Domain"' ) Do If %%b' Neq ' (Set C_=%%b) Else (Set D_=%%a)If /i %D_% Neq %C_% Net Stop %FW%You'd need to change ServiceName.ext in line 2 to the name of the service you need to stop.
cyber_killer Posted December 29, 2008 Author Posted December 29, 2008 Can you please explain this in few words ?
Yzöwl Posted December 29, 2008 Posted December 29, 2008 Okay, although it appears to me that this is pretty one-sided affair!Goal:Check to see if the user has logged on successfully to a Domain.If so, Stop the non-required serviceMethod:Parse the output of NET CONFIG WORKstationIf LOGON DOMAIN is not the same as the FULL COMPUTER NAME then the user is logged onto a domain and the service is stopped.There may be other ways to do it, but since the information you provided was sparse, I was unable to provide anything better.
jaclaz Posted December 29, 2008 Posted December 29, 2008 Can you please explain this in few words ?Read this:http://www.robvanderwoude.com/ntfortokens.htmlTry opening a console and issueing this command:Net Config Workstationthen try issueing:Net Config Work(it will give the same output)Try the above both when connected and when not connected to a domain.then try issueing:tasklistThen read this:http://www.ss64.com/nt/net_service.htmljaclaz
cyber_killer Posted January 8, 2009 Author Posted January 8, 2009 Tnx for the help guys. The script is working.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now