Jump to content

Argh, it only works in win2k3


 Share

Recommended Posts

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.

#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
Link to comment
Share on other sites

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_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

My 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?

:whistle:

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
Link to comment
Share on other sites

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 by win2k
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...