Thursday, March 19, 2015

SIDFetch

PsGetsid.exe ANSI to TEXT Conversion Scripts
.....................................................................................................................................................................................................................................................................................................................................

SID Conversion

on error resume next
Const ForReading = 1
Const TristateTrue = -1 'UniCode
Dim WshShell : Set WshShell = CreateObject("WScript.Shell")
Windir = WshShell.ExpandEnvironmentStrings("%windir%")
FilePath = windir & "\Temp\userSID.txt"
'Convert supplied file to Ansi_File.txt

Set oFSO = CreateObject("scripting.filesystemobject")
Set oFile = oFSO.GetFile(FilePath)

Set oFileIn = oFSO.OpenTextFile(oFile.Path,ForReading,,TristateTrue)
Set oFileOut = oFSO.CreateTextFile(oFile.ParentFolder & "\ansi_" & oFile.Name,True,False)

oFileOut.Write oFileIn.ReadAll

SID Reader

Const ForReading = 1
Dim objWshShell : Set objWshShell = CreateObject("WScript.Shell")
Dim WshShell : Set WshShell = CreateObject("WScript.Shell")
Dim str1, Windir
Set objFSO = CreateObject("Scripting.FileSystemObject")
Windir = WshShell.ExpandEnvironmentStrings("%windir%")
Set objFile = objFSO.OpenTextFile(windir & "\Temp\ansi_userSID.txt", ForReading)

Do Until objFile.AtEndOfStream
    strNextLine = objFile.ReadLine
    If Len(strNextLine) > 0 Then
        strLine = strNextLine
    End If
Loop

objFile.Close
'Wscript.Echo strLine
str1 = "HKEY_LOCAL_MACHINE\SOFTWARE\SID\Current_UName\Usersid"

WshShell.Regwrite str1 ,strLine, "REG_SZ"


No comments:

Post a Comment