Saved Bookmarks
| 1. |
Solve : Script created to change log on account/password services help? |
|
Answer» i'm trying to write a script to stop a group of services , change the Log on name / set password for each service and then start then back up. For this examples I used the BITS Service in windows ..... What I have so far are as FOLLOWS: I'm not sure about MUCH of this and any help would grateul! sc query state= all | grep "SERVICE_NAME: BITS" > C:\sc.out -----------------Start Services Change Script------------------- sc config OBJ= TeeCee etc. sc stop . . . sc start . . . C:\>sc stop sc stop [BITS] C:\>sc start sc start [BITS] ... C:\>sc config SYNTAX: sc config [BITS] DisplayName= password= ... CONFIG OPTIONS: NOTE: The option name includes the equal sign. type= start= error= binPath= group= tag= depend= obj= DisplayName= password= ---------------END-------------------------------------- It would seem you already have your code, you just need to put it together. Code: [Select]sc <server> stop [BITS] sc <server> config [BITS] obj=TeeCee DisplayName=<TESTUSER> Password=password sc <server> start [BITS] I don't use batch for a lot of network things, and this is untested.What would you suggest? I am trying to create something to run for a group of services... Its about 8 services that I always changed per clients server to the correct domain\Log On and Password save it and restart services but i have to do this for each of them everytime on tons of different servers so i was trying to find a better way.. Thanks for the help !!!!!!"It would seem you already have your code, you just need to put it together. Code: [Select] sc stop [BITS] sc config [BITS] obj=TeeCee DisplayName= Password=password sc start [BITS] I don't use batch for a lot of network things, and this is untested." and YES anything to help me put this together is greatly appriciated!Try this batch file. You will need to create a plain text list (in notepad) of servers using a carraige return to seperate them. I.e. >>List.txt<< server1 server2 server3 etc. You will also need to fill in the [service1],[service2] in the below code with the services you are needing to change. Most of this code just allows you to run the batch file and determine the username and password when you run it instead of having to modify the batch every time. If the services tend to change often, you may want to run an embedded "for" loop to help alleviate your need to modify the batch program. Let me know if you would like to see that coded out. Code: [Select]echo off :username cls echo. echo Enter the UserName set /p user={User} cls echo. echo %user% echo. echo Is this correct? set /p yn1={y/n} if /i "%yn1%"=="y" goto password goto username :password cls echo. echo Enter the password set /p pass={Password} cls echo. echo %pass% echo. echo Is this correct? set /p yn2={y/n} if /i %yn2%"=="y" goto services goto password :services for /f "delims=" %%A in (List.txt) do ( sc %%A stop [service1] sc %%A config [service1] obj=TeeCee DisplayName=%user% Password=%pass% sc %%A start [service1] sc %%A stop [service2] sc %%A config [service2] obj=TeeCee DisplayName=%user% Password=%pass% sc %%A start [service2] ...lather, rinse, repeat... ) Thank you kind sir! What I have is as follows: I created a list.txt and placed it in my root (C) , i'm also not sure what belongs in the field... i'm assuming my computer name , but after running it i'm getting a syntex error Thoughts? echo off :username cls echo. echo Enter the UserName set /p user={User} cls echo. echo %user% echo. echo Is this correct? set /p yn1={y/n} if /i "%yn1%"=="y" goto password goto username :password cls echo. echo Enter the password set /p pass={Password} cls echo. echo %pass% echo. echo Is this correct? set /p yn2={y/n} if /i %yn2%"=="y" goto services goto password :services for /f "delims=" %%A in (List.txt) do ( sc %%A stop [BITS] sc %%A config [BITS] obj=TeeCee DisplayName=%user% Password=%pass% sc %%A start [BITS] sc %%A stop [BITS] sc %%A config [BITS] obj=TeeCee DisplayName=%user% Password=%pass% sc %%A start [BITS] ...lather, rinse, repeat... ) Quote from: animalkrack3r on November 30, 2011, 04:49:20 PM Code: [Select]for /f "delims=" %%A in (List.txt) do (*chuckles* I love how you used the exact script... you can take out the lather, rinse, repeat line, it was in there so you would know that any additional services you wanted to update would have the same syntax as what you see there. The server name needs to be the full computer name of the server. I.e. if you are on a domain, it needs to have the "dot domain name" included. If it is just your computer (or just the computer that it is going to run on), you can actually replace that with a "." and you will accomplish the same thing. If it is the same services that have to be configured on each server then wy not make a text file with the services that need to be configured and create an inner for loop to parse that as well.lol excuse my extreme noobness with batch files, thank you very very much Raven! Squashman, explain ? thanks! |
|