locked
How to find out the logged on username when VBS is kicked off by system account? RRS feed

  • Question

  • I have to write some registry values to:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft Forefront\Client Security\1.0\AM\Exclusions\Paths
    The values that are going into that key are Temp Interment Java Script files that I do not want Forefront to scan.  The Machines are not on our domaon (managed by LanDesk Gateway) so I can not use GPO or FCS policies to manage exclusions, fun.  So I have a little script that writes the values into the key fine, with one execption.  The path to the Temp Internet Files

    C:\documents and Settings\SYSTEM\Local Settings\Temporary Internet Files\ ... I want system to be the user that logged into the machine. System is who kicked off the script. 

    How do I get the script to find out who the logged in use is and not who kicked off the script?

    I am a scripting novis...this is what I have put togeather...

    Const HKEY_LOCAL_MACHINE = &H80000002
    strComputer = "."
    Set StdOut = WScript.StdOut
    Set oNet = CreateObject("wscript.network")
     
    Const ForReading = 1
    
    i = 0
    Set objFS = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFS.OpenTextFile("C:\Scripts\js.txt", ForReading)
    Do Until objFile.AtEndOfStream
        i = i + 1
        strJS = objFile.ReadLine
     
    
    Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_ 
    strComputer & "\root\default:StdRegProv")
     
    strKeyPath = "SOFTWARE\Microsoft\Microsoft Forefront\Client Security\1.0\AM\Exclusions\Paths"
    strValueName = "C:\documents and Settings\" & oNet.UserName & "\Local Settings\Temporary Internet Files\" & strJS
    
    dwValue = 0
    oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue	
    
    Loop
    Thanks for the help,
    Bryan
    Friday, May 22, 2009 6:27 PM