Solved Noob VBS scripter needs Help!!!

October 19, 2012 at 08:21:10
Specs: Windows 7
Okay i need to be able to write a vb script that i can type in something i.e. computer name, and it then searches a text file that has a computer name along with the user name, and then DISPLAYS the User name back to me!!!!! Anyone school me in this please!!

See More: Noob VBS scripter needs Help!!!

Report •


#1
October 19, 2012 at 10:08:24
✔ Best Answer
::Here is a start
@echo off
:change
>$$$.vbs echo wsh.echo inputbox("PLease enter the computer name","SEARCH STRING PROMPT","computer name")
for /f "tokens=*" %%a in ('cscript//nologo $$$.vbs') do set var1=%%a
>$$$.vbs echo wsh.echo inputbox("Please enter the text file with the following format","TEXT FILE PROMPT","c:\textfile")
for /f "tokens=*" %%a in ('cscript//nologo $$$.vbs') do set var2="%%a"
TYPE %var2% | FINDSTR %var1%
pause

:: mike


Report •

#2
October 19, 2012 at 10:14:24
That worked awesome, is there a way to set in the text file or will i always need to type it in?

Report •

#3
October 19, 2012 at 10:27:26
>$$$.vbs echo wsh.echo inputbox("Please enter the text file with the following format","TEXT FILE PROMPT","c:\textfile")

on this line change c:\testfile to whatever you want as long as its in that format

glad it worked

:: mike


Report •

Related Solutions

#4
October 19, 2012 at 10:31:04
>$$$.vbs echo wsh.echo inputbox("Please enter the text file with the following format","TEXT FILE PROMPT","c:\textfile")
for /f "tokens=*" %%a in ('cscript//nologo $$$.vbs') do set var2="%%a"
TYPE %var2% | FINDSTR %var1%

perminent fix :remove the above then add
TYPE c:\yourfilenamehere | FINDSTR %var1%

:: mike


Report •

#5
October 19, 2012 at 10:43:40
Question: The original question was about VBScript. Why are we wrapping that up in a batch file?

How To Ask Questions The Smart Way


Report •

#6
October 19, 2012 at 10:50:33
whoops, I did in fact cheat and use something I already had. My regrets to the original poster. ( Thanks Razor2.3)

:: mike


Report •

#7
October 20, 2012 at 07:14:21
sorry for the delay, I had to read up on a way to easily do this without the batch, if someone has an easier way let me know. :-D.

Const ForReading = 1
strMessage =Inputbox("Enter Computer Name","Input Required")

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\USER1.txt", ForReading)
'change c:\User1.txt to your name of file
Do
    strSearchString = objFile.ReadLine
    If strSearchString = strMessage Then 
       Wscript.Echo strSearchString 
    End If
Loop Until objFile.AtEndOfStream

objFile.Close


:: mike


Report •

#8
October 20, 2012 at 09:08:50
I'm waiting for the file layout before I attempt anything, honestly.

How To Ask Questions The Smart Way


Report •

#9
October 20, 2012 at 09:28:02
I figured if the first cheater way worked that the second would, however as you can probably tell I tend to assume. Thanks for the feedback, I am not as experienced with VBScript as I should be, so I went with what I knew in the first place

:: mike


Report •

Ask Question