Ask a Question

Get current Windows user SID


Get current Windows user SID

Hello everyone,


I am looking for a way to get the current Windows user SID during script execution. Part of our regression testing requires that we verify deleting an item within our application moves it to the Recycle Bin. Online research has uncovered that the path to the recycle bin is C:\$Recycle.bin\<Windows User SID>.


So, I could use some help writing a JScript script to get this information. Has anyone done this before?


PS: You can see your SID from the command prompt using this:

whoami /user
SmartBear Alumni (Retired)

Hi almmatt,


Try this:


function getSID()
  var oWMI = GetObject("winmgmts:");
  var oAccount = oWMI.Get("Win32_UserAccount.Name='" + Sys.UserName + "',Domain='" + Sys.DomainName + "'");
  return oAccount.SID;

Helen Kosova
SmartBear Documentation Team Lead
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

Thank you very much! That is exactly what I needed!

Showing results for 
Search instead for 
Did you mean: