2

I'm currently making a stupid UI(User Interface) for a bunch of scripts I've made with vbs. For the beginning of the script you can choose a "Setup" option. It asks for you name and stuff. Anyways, what I'm trying to do is have a script so it saves the name that is inputted and used the next time the program is ran if they don't choose the setup option. Here's the part where it happens.

Entry = Inputbox("Welcome To The Solus Project!" & vbNewLine & "" & vbNewLine & "Enter" & vbNewLine & "Setup" & vbNewLine & "Quit", "Solus Entry")
If Entry = "Setup" Then
InputName = Inputbox("Please Enter Your Name", "Name")
ElseIf Entry = "Quit" Then
Wscript.Quit
ELseIf Entry = "Enter" Then

So once it saves the name to the variable "Entry" I'd like to be able to use it later if the script is re-run so people don't have to constantly use the "Setup" option to refresh their name. Thanks in advance,

-BTH

1 Answer 1

1

Save the entered name afterwards in a local file and read from it - if possible - at the beginning of the script. Simple quick & dirty example could look like so:

Set objFso = CreateObject("Scripting.FileSystemObject")
nameFilePath = "saved_name.txt"
InputName = ""

If (objFso.FileExists(nameFilePath)) Then
    Set objFile = objFso.OpenTextFile(nameFilePath)
    InputName = objFile.ReadLine
    objFile.Close
End If

Entry = Inputbox("Welcome To The Solus Project!" & vbNewLine & "" & vbNewLine & "Enter" & vbNewLine & "Setup" & vbNewLine & "Quit", "Solus Entry")
If Entry = "Setup" Then
    InputName = Inputbox("Please Enter Your Name", "Name")
    Set objFile = objFso.CreateTextFile(nameFilePath, True)
    objFile.Write InputName
    objFile.Close
ElseIf Entry = "Quit" Then
    Wscript.Quit
ElseIf Entry = "Enter" Then
    ' Some other stuff
End If

WScript.Echo InputName
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.