Capture users login, computer name and variable

Hi all.  I am looking for a little script VBS that can write to a text file, the username and computer name of the logged in user as well as popping up a message box that asks a question and then adds this information to the file when pressing ok?  anyone have one?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Here is a login logoff script.  You may have to customize your own a little for what you want.
Like this?
'On Error Resume Next
Const ForReading = 1, ForWriting = 2, ForAppending = 8

strComputer = "."
Set objShell = CreateObject("WScript.Shell")
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") 
Set objFSO = CreateObject("Scripting.FileSystemObject")

envUserName = objShell.ExpandEnvironmentStrings("%username%") : envCompName = objShell.ExpandEnvironmentStrings("%computername%")
strInput =  InputBox("Enter your popup here")
Sub CreateLog
	strLogFile = envUserName&".txt"
	If objFSO.FileExists(strLogFile) then
		Set objLogFile = objFSO.OpenTextFile(strLogFile,ForAppending)
		Set objLogFile = objFSO.CreateTextFile(strLogFile,True)
	End If
End Sub

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
I tried this out and it worked. Make sure you save the file as .vbs and have the text file already created.
Const ForReading = 1
Const ForAppending = 2

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("\\server\path\input.txt", ForReading)

strInput = Inputbox("Input dialogue.")

Set WshNtwk = WScript.CreateObject("WScript.Network")
PropertyINfo = "User Input" & vbTab & "=  " & strInput & vbCrLf & _
"Computer Name" & vbTab & "=  " & WshNtwk.ComputerName  & vbCrLf & "User Name" _
  & vbTab & "=  " & WshNtwk.UserName   & vbCrLf

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set OFile = oFSO.OpenTextFile("\\server\path\info.txt", ForAppending)
oFile.WriteLine PropertyInfo

Open in new window

stefanjocAuthor Commented:
Perfect many thanks.  Many thanks to all who contributed to this answer as always.  :-)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.