Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
#DefineFunction GetRemoteLoggedInUser(computername) ; connect to the registry of the workstation being queried errormode(@off) hnd = RegConnect(computername,@regusers) errormode(@cancel) if hnd==0 return 0 endif ; get list of user keys userlist = RegQueryKeys(hnd) numusers = ItemCount(userlist,@tab) RegCloseKey(hnd) errormode(@off) hnd = RegConnect(computername,@regmachine) errormode(@cancel) if hnd==0 return 0 endif if numusers > 1 loggedonuser = ItemExtract(2,userlist,@tab) hnd2 = RegOpenKey(hnd,StrCat("SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\",loggedonuser)) datatype = RegEntryType(hnd2,"[profileimagepath]") path = RegQueryEx(hnd2,"[profileimagepath]",@tab,datatype) user = ItemExtract(-1,path,"\") else user = "*NONE*" endif ; cleanup RegCloseKey(hnd) RegCloseKey(hnd2) AddExtender("WWWNT34i.DLL") errormode(@off) WNTCancelCon(StrCat(computername,"\ipc$"),@TRUE,@TRUE) errormode(@cancel) return user #EndFunction pcname = "\\FRED" ret = GetRemoteLoggedInUser(pcname) if ret == 0 Message(StrCat("GetRemoteLoggedInUser Error on ",pcname),"Unable to Connect to Remote Machine") endif if ret == "*NONE*" Message(StrCat("GetRemoteLoggedInUser Error on ",pcname),"No Users Logged in.") endif Message(StrCat("GetRemoteLoggedInUser on ",pcname),ret)Note: Maybe Ping the workstation first to make sure it's accessible.
Article ID: W16035File Created: 2004:03:30:15:42:22Last Updated: 2004:03:30:15:42:22