Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: get user sid wntUserProps
Platform is NT4 Wkst. I'm hoping for something like getsid on NTResKit, but that utility doesn't exist on the computer that I'm writing the script for.
AddExtender("WWWNT34i.DLL") SID=wntAcctInfo(server_name,account_name,1) Message("SID for %account_name%:", SID)
In the meantime, this is something I use to determine who is logged on to a remote workstation. Maybe you can use it for your purposes.
Basically, all it does is pull the SID of all logged on users from HKU and matches it to a key under HKLM that provides the profile path for that user. The lowest level directory is the user's ID. I then parse out the username from that path.
Keep in mind that ".Default" is always present under HKU and is always first in the list. That's why a count of '1' means no one is logged on.
errormode(@off) regclosekey(hnd) hnd2 = RegConnect("\\%pcname%",@regusers) errormode(@cancel) hnd3=RegOpenKey(hnd2,"") userlist = regquerykeys(hnd3) numusers = itemcount(userlist,@tab) RegCloseKey(hnd3) if numusers == 1 changestatus = strcat(printerips," No user logged on") boxdestroy(wbid) goto main endif errormode(@off) ;careful with this one, turn it back on regclosekey(hnd2) hnd2 = RegConnect("\\%pcname%",@regmachine) errormode(@cancel) id = "" for i = 2 to numusers loggedonuser = itemextract(i,userlist,@tab) hnd = regopenkey(hnd2,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\%loggedonuser%") path = regqueryex(hnd,"[profileimagepath]",@tab,2) pathlen = strlen(path) backslash = strindex(path,"\",0,@backscan) idlen = pathlen - backslash if i == 2 id = strsub(path,backslash + 1,idlen) else id = strcat(id," ,",strsub(path,backslash + 1,idlen)) endif next
Article ID: W14884
File Created: 2002:05:22:11:24:14
Last Updated: 2002:05:22:11:24:14