Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
AddExtender("WWWNT34i.DLL") AddExtender("wwsop34i.DLL") ;Define Functions first #DefineFunction svcstart(dname,name,svc) aStatusbar(0,StrCat("Starting ",dname),StrCat("Starting the ",svc," service"),60,0) ;<--- start the status bar before the wntSvcStart() wntSvcStart(name, svc, 1000, "", "") ; start the service xx=0 While 1 ; loop until the service is running xx = xx+1 aStatusbar(1,StrCat("Starting ",dname),StrCat("Starting the ",svc," service"),60,xx+1) ;<--- it will start looking weird if it takes longer than 60 seconds ret = wntSvcStatus(name,svc,1000,2) If ret == 4 Then Break ; if running, break out of the while loop TimeDelay(1) EndWhile aStatusbar(1,StrCat("Starting ",dname),StrCat("Starting the ",svc," service"),60,60) ;<--- make it look like the status bar is at 100 percent during your Display() message TimeDelay(1) aStatusbar(2,StrCat("Starting ",dname),StrCat("Starting the ",svc," service"),60,60) ;<--- kill the status bar #EndFunction #DefineFunction svcstop(dname,name,svc) aStatusbar(0,StrCat("Stopping ",dname),StrCat("Stopping the ",svc," service"),60,0) ;<--- start the status bar before the wntSvcStart() wntSvcControl(name, SVC, 1000, 1) ; stop the service xx = 0 While 1 ; loop until the service is stopped xx = xx+1 aStatusbar(1,StrCat("Stopping ",dname),StrCat("Stopping the ",svc," service"),60,xx) ;<--- this will look weird if it takes longer than 60 seconds ret = wntSvcStatus(name,svc,1000,2) If ret == 1 Then Break ; if stopped, break out TimeDelay(1) EndWhile aStatusbar(1,StrCat("Stopping ",dname),StrCat("Stopping the ",svc," service"),60,60) ;<--- make it look like it's at 100 percent during your Display() message TimeDelay(1) aStatusbar(2,StrCat("Stopping ",dname),StrCat("Stopping the ",svc," service"),60,60) ;<--- kill the status bar #EndFunction ; Run Program name = AskLine("Server Name", StrCat("IP Address",@CRLF,"leave blank for local machine"), "192.168.0.100") :top IntControl(73, 1, 0, 0, 0) grp1 = 1; both application services & device drivers grp2 = 300; both active and inactive services grp3 = 0; only applys if "service/group-name" contains a service name flag = grp1 + grp2 + grp3 list = wntSvcList( name, "", flag) SVC=AskItemlist("List of all Services", list,@TAB, @UNSORTED, @SINGLE) ;If error ;goto fail ;end if ;;ADJUST THE NAME OF SELECTED SERVICE LENGTH=StrLen(SVC) LENGTH =LENGTH-2 svc = StrFix(SVC, "", LENGTH) state = wntSvcStatus(name, svc,1000, 2) ; get the current state of the selected service dname=wntSvcCfgGet(name, svc, 1000, 9) ;get the Display name Switch state Case 1 q = AskYesNo (StrCat(dname," SERVICE STOPPED"), "Would you like to start it?" ) If q == @NO Then GoSub top a=svcstart(dname,name,svc) Display(3, StrCat(dname,' Service Started'), 'Done') Break Case 4 q = AskYesNo (StrCat(dname," SERVICE RUNNING"),"Would you like to stop it?" ) If q == @NO Then GoSub top svcstop(dname,name,svc) Display(3, StrCat(dname,' Service Stopped'), 'Done') Break EndSwitch Exit :WBERRORHANDLER curuser=wntGetUser(@DEFAULT) ;This is how you are authenticated now q = AskYesNo ("Current User",StrCat("You are logged in as ",curuser," Would you like to change it?")) ;Q-do you want to change how you are logged in? Select q Case @YES user= AskLine ("Administrator Name","Please enter USER name","Administrator") pswd= AskPassword("Administrator Password", "Please enter your password") Continue Case @NO GoSub top Continue End Select ;add share ErrorMode(@OFF) test = wntAddDrive(user,pswd,StrCat("\\",name,"\c$"),"S:",@FALSE) ErrorMode(@CANCEL) TimeDelay(1) If test != @TRUE Message ("Authentication Failed", StrCat("Connections failed to authenticate or timed out.",@CRLF,"Retry program.") ) Exit EndIf GoSub top
Article ID: W17214
File Created: 2007:07:03:14:28:50
Last Updated: 2007:07:03:14:28:50