My VB.net written application is being executed by an MSI file, and I need to get the currently logged on user (who is running the MSI). This is because I am importing xml files
You could potentially try using WMI:
Dim username, objItem
Dim objWMIService : Set objWMIService = GetObject( "winmgmts:\\.\root\cimv2" )
Dim colItems : Set colItems = objWMIService.ExecQuery( "Select * from Win32_ComputerSystem" )
For Each objItem in colItems
username = objItem.UserName
if (instr(username ,"\") > 0) Then
username = Split(username, "\")(1)
end if
Next
msgbox username
Or Quser:
Dim strCmd : strCmd = "cmd /q /c for /f ""skip=1 tokens=1"" %a in ('quser console') do @echo %a"
username = CreateObject("WScript.Shell").Exec(strCmd).StdOut.ReadAll()
username = Right(username,Len(username)-1)
msgbox username