Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

window scripting

Options
  • 27-07-2004 1:50pm
    #1
    Registered Users Posts: 68 ✭✭


    I'd like have all the users associated with a particular login script execute a vbs script that will write the following information to a text file on a network share.

    The users login name
    The users actual name
    The PC to which the user is signing on

    This script has to run on the following platforms NT4 PC's with WMI installed/Windows 2000/Windows XP


    I think these reg entries may help but there might also be WMI variables im not aware of.

    Registry keys
    login name:
    HKCU\Microsoft\Windows\CurrentVersion\Explorer\Logon User Name
    actual name:
    HKLM\System\CurrentControlSet\Services\lanmanserver\parameters\srvcomment
    PC name:
    HKLM\System\ControlSet001\Control\ComputerName\ActiveComputerName\ComputerName

    Any ideas?


Comments

  • Closed Accounts Posts: 1,746 ✭✭✭0utshined


    Hi Alan,

    You don't have need to go into the registry for this. You can use the Network object.


    var WshNetwork = WScript.CreateObject("WScript.Network")
    WScript.Echo("Domain = " + WshNetwork.UserDomain)
    WScript.Echo("Computer Name = " + WshNetwork.ComputerName)
    WScript.Echo("User Name = " + WshNetwork.UserName)


    Regards,
    0


  • Registered Users Posts: 68 ✭✭alancool


    Tanx 4 replying Outshined.
    I tried your script (saving it as inventory.vbs and inventory.wsh) and it did not work. My batch file approach was a simple one line:
    echo %username% %computername% %os% >> F:\log.txt but how do I reference the environment variables in a script, maybe I'm not saving it right? :confused:

    In addition I've had to return to the registry to get a fourth piece of info "is the screensaver password enabled?"

    I got this far with Technet. If the password is enabled create the file pwdenabled else create the file pwddisabled.

    const HKEY_CURRENT_USER = &H80000001
    strComputer = "."
    Set StdOut = WScript.StdOut
    Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
    strComputer & "\root\default:StdRegProv")
    strKeyPath = "Control Panel\Desktop"
    strValueName = "ScreenSaverIsSecure"
    oReg.GetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue
    If strValue = 1 Then
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    strFileName = "pwdenabled"
    Set objFile = objFSO.CreateTextFile(strFileName)
    objFile.Close
    Else
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    strFileName = "pwddisabled"
    Set objFile = objFSO.CreateTextFile(strFileName)
    objFile.Close
    End If


    I would like the results to appear in a log file something like this

    %username% %computername% %os% %screensaver enabled/disabled%

    Any ideas?? tanx again :confused:


  • Closed Accounts Posts: 92 ✭✭tempest


    Should do it for you.....

    Dim WshNetwork
    Set WshNetwork = WScript.CreateObject("WScript.Network")

    Dim WshShell
    Set WshShell = WScript.CreateObject("WScript.Shell")

    Dim fso
    Set fso = WScript.CreateObject("Scripting.FileSystemObject")

    Dim ts

    Set ts = fso.CreateTextFile("C:\Test.txt")

    Dim username

    username = WshNetwork.UserName

    Dim computername

    computername = WshNetwork.ComputerName

    Dim intscreensaverenabled
    Dim strscreensaverenabled
    intscreensaverenabled = WshShell.RegRead("HKCU\Control Panel\Desktop\ScreenSaverIsSecure")

    strscreensaverenabled = "false"

    if intscreensaverenabled = 1 Then
    strscreensaverenabled = "true"
    end if

    Dim osname
    osname = WshShell.RegRead("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\ProductName")

    ts.WriteLine(username + " " + computername + " " + osname + " " + strscreensaverenabled)

    ts.close


  • Registered Users Posts: 68 ✭✭alancool


    many many tanx Tempest, that worked a treat!! :D


Advertisement