win2k Posted August 9, 2006 Posted August 9, 2006 Ok, So this code just writes a key to the registry to set a depndency for a service. Well that works fine but when it comes to setting up the service to log on under a certain username, it will only work in windows 2003 and not windows 2000. Can anyone find anything wrong with this code ? I dont know if maybe microsoft changed the syntax of how you should use SC.exe from win2k and win2k3 or what. Any help would be great. expandcollapse popup#include <process.au3> #include <_NTServices.au3> HotKeySet("{END}", "Terminate") Dim $Domain_Name dim $comp_name=@ComputerName dim $temp dim $edmmt="\edmmtsadmin";This is just for the log in information Dim $Stopstatus Dim $Startstatus Const $service= "DVFaxNotifyServer" Const $pass = "password" const $dirPath = "C:\DV\MasPass\NetLogon" ;Change this variable to What you want the login name to be if you have to pull it from the registry $temp=RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Reynolds&REYNOLDS\DV","Domain") ;This is changing the login name from either what you pulled from the registry or just the computer name If $temp="" Then $Domain_Name=$comp_name Else $Domain_Name=$temp endif ;setting up the registry keys RegDelete("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DVFaxNotifyServer", "DependOnService") RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DVFaxNotifyServer","DependOnService","REG_MULTI_SZ","RPCSS" & @LF & "Fax" ) ;Brings up a command window in the background $rc = _RunDos("sc config " & $service & " start= auto" & " obj= " & $Domain_Name & $edmmt & " password= " & $pass ) $Stopstatus = _ServiceStop( _ToInternalServiceName("DVFaxNotifyServer") ) sleep(300) $Startstatus = _ServiceStart( _ToInternalServiceName("DVFaxNotifyServer") ) sleep(300) ;$rc = _RunDOS("net share NETLOGON /delete") ;$rc = _RunDos("net share NETLOGON="& $dirPath) Func Terminate() Exit 0 EndFunc
PsaltyDS Posted August 9, 2006 Posted August 9, 2006 Ok, So this code just writes a key to the registry to set a depndency for a service. Well that works fine but when it comes to setting up the service to log on under a certain username, it will only work in windows 2003 and not windows 2000. Can anyone find anything wrong with this code ? I dont know if maybe microsoft changed the syntax of how you should use SC.exe from win2k and win2k3 or what. Any help would be great. CODE#include <process.au3>#include <_NTServices.au3>HotKeySet("{END}", "Terminate")Dim $Domain_Namedim $comp_name=@ComputerNamedim $tempdim $edmmt="\edmmtsadmin";This is just for the log in informationDim $Stopstatus Dim $StartstatusConst $service= "DVFaxNotifyServer"Const $pass = "password"const $dirPath = "C:\DV\MasPass\NetLogon";Change this variable to What you want the login name to be if you have to pull it from the registry$temp=RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Reynolds&REYNOLDS\DV","Domain");This is changing the login name from either what you pulled from the registry or just the computer nameIf $temp="" Then $Domain_Name=$comp_nameElse $Domain_Name=$tempendif ;setting up the registry keysRegDelete("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DVFaxNotifyServer", "DependOnService")RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DVFaxNotifyServer","DependOnService","REG_MULTI_SZ","RPCSS" & @LF & "Fax" );Brings up a command window in the background$rc = _RunDos("sc config " & $service & " start= auto" & " obj= " & $Domain_Name & $edmmt & " password= " & $pass ) $Stopstatus = _ServiceStop( _ToInternalServiceName("DVFaxNotifyServer") )sleep(300)$Startstatus = _ServiceStart( _ToInternalServiceName("DVFaxNotifyServer") )sleep(300);$rc = _RunDOS("net share NETLOGON /delete");$rc = _RunDos("net share NETLOGON="& $dirPath)Func Terminate() Exit 0EndFuncMy Win2KAS server doesn't even have SC.exe on it. My XP Pro workstation and Win2K3 server both do, and the command syntax matches what you appear to want. So, what happens on your Win2K box when you run that SC command manually from a CMD window? What does $rc get set to? Have you tried it with RunWait(@ComSpec & " /k "...) yet, which leaves the command window open after execution? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
win2k Posted August 9, 2006 Author Posted August 9, 2006 (edited) When i do this manually in the command window i just get an error returned saying [sC] ChangeServiceConfig Failed 87: The parameter is incorrect. The really wierd thing is that if i just go to the services window, log the service in and then set it back to local system, the script works fine. The only other thing i can think of to set up a service while logged out of the computer would be to somehow add keys to the registry. I dont have a clue as to how you do that though. I know how to change the login name for the service but not how to set the password via the registry Edited August 9, 2006 by win2k
win2k Posted August 9, 2006 Author Posted August 9, 2006 Actually, I think i figured out a way around the SC.exe failing. I can change the login name via the registry and then it stops the service, then use SC.exe to add the password and then start the service. Seems to be working ok
bluebearr Posted August 9, 2006 Posted August 9, 2006 According to this page it appears that sc.exe was a Win2K resource kit utility. As such, it doesn't surprise me that the syntax may have changed.Here is Microsoft's article on the syntax. It looks the same as what you have.Try peeling off options to see if you can pinpoint which one is causing the trouble. For example, if you leave off obj and password, it will use LocalSystem by default. See if that works. BlueBearrOddly enough, this is what I do for fun.
win2k Posted August 9, 2006 Author Posted August 9, 2006 According to this page it appears that sc.exe was a Win2K resource kit utility. As such, it doesn't surprise me that the syntax may have changed.Here is Microsoft's article on the syntax. It looks the same as what you have.Try peeling off options to see if you can pinpoint which one is causing the trouble. For example, if you leave off obj and password, it will use LocalSystem by default. See if that works.SC.exe is having fits with changing the obj= of a service. If you changed the name in the registry you can still use SC to change the password. its really wierd
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