Hi!
I'm trying to write a Script to read and change some Data from local and remote computers aswell.
I found the scriptlets here:
http://www.autohotkey.com/forum/topic65688.html
I changed them slightly so that ony infos that I need are read.
I need: Computername, Domain/Workgroup, Owner and Company to read and change.
I've written a little testscript to (first of all) read the data.
My problem is, while reading the data locally works fine, remote it doesn't work.
Mostly, I got the errors "RDP-Server not avaliable" or "Access Denied".
I'm not sure that it's the script or the connection.
Code:
strComputer := "andreas-netbook"
strNamespace := "\root\CIMV2"
strUser := "Administrator"
strPassword := ""
If strComputer in .,%A_ComputerName%
{
objWMIService := ComObjGet("winmgmts:{impersonationLevel=impersonate}!\\" strComputer strNamespace)
} Else {
objSWbemLocator := ComObjCreate("WbemScripting.SWbemLocator")
objWMIService := objSWbemLocator.ConnectServer(strComputer, strNamespace, strUser, strPassword)
objWMIService.Security_.ImpersonationLevel := 3
objWMIService.Security_.authenticationLevel := 6
}
colSettings := objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
for setting in colSettings {
A_DomainName := setting.Domain
A_IsDomain := setting.DomainRole
Break
}
A_Owner := RegistryRead("HKLM", "SOFTWARE\Microsoft\Windows NT\CurrentVersion", "RegisteredOwner", strComputer)
A_Company := RegistryRead("HKLM", "SOFTWARE\Microsoft\Windows NT\CurrentVersion", "RegisteredOrganization", strComputer)
Msgbox, Owner: %A_Owner%`nFirma: %A_Company%`nDomain or Workgroup: %A_DomainName%`nIs in Domain: %A_IsDomain%
ExitApp
RegistryRead(RK, SK, V="", remote="") {
remote := StrLen(remote) ? "\\" remote ":" : ""
RegRead, Var, %remote%%RK%, %SK%, %V%
Return, Var
}
* To test the script you may have to change the variables *
THXIA
EDIT: BTW: I'm using AHK_L v1.1.00.00