Shutdown using 2 variables

i have 2 listbox's, a radiobutton, and an "execute" button.

so far i have, the user can designate a time period for their computer to shutdown, if you look in your command prompt you can include a comment on the shutdown. "-c". i want textbox2 to be able to determine what the user wants to write as the comment on the shutdown.

If RadioButton1.Checked Then Shell("shutdown -s -f -t " & TextBox1.Text)
asherapAsked:
Who is Participating?
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.

RonaldBiemansCommented:
like this

Shell("shutdown -s -f -t " & TextBox1.Text & " -c " & TextBox2.Text)
0

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
asherapAuthor Commented:
yeah taht works perfectly, but the only thing is if i dont have a comment i cant even do a shutdown normally
0
RonaldBiemansCommented:
Well do a check beforehand then, like

if textbox2.text = "" then
      Shell("shutdown -s -f -t " & TextBox1.Text)
else
      Shell("shutdown -s -f -t " & TextBox1.Text & " -c " & TextBox2.Text)
endif
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

asherapAuthor Commented:
ok i will show u what code i have so far and can you rewrite what i will need
p.s i have upped the point value 50

If TextBox2.Text = "" Then
            Shell("shutdown -s -f -t " & TextBox1.Text)
        Else
            Shell("shutdown -s -f -t " & TextBox1.Text & " -c " & TextBox2.Text)
        End If

        If RadioButton1.Checked Then Shell("shutdown -s -f -t " & TextBox1.Text & " -c " & TextBox2.Text)
        If RadioButton2.Checked Then Shell("shutdown -r -f -t " & TextBox1.Text & " -c " & TextBox2.Text)


problem is still if i dont enter a comment it doesn work
0
RonaldBiemansCommented:
      If TextBox2.Text = "" Then
          If RadioButton1.Checked Then Shell("shutdown -s -f -t " & TextBox1.Text)
        Else
            If RadioButton2.Checked Then Shell("shutdown -r -f -t " & TextBox1.Text & " -c " & TextBox2.Text)
        End If

       
0
asherapAuthor Commented:
thanks but i had to modify the code a little bit to suit my program it ended up being,

If TextBox2.Text = "" Then
            If RadioButton1.Checked Then Shell("shutdown -s -f -t " & TextBox1.Text)
            If RadioButton2.Checked Then Shell("shutdown -r -f -t " & TextBox1.Text)
        Else
            If RadioButton2.Checked Then Shell("shutdown -r -f -t " & TextBox1.Text & " -c " & TextBox2.Text)
            If RadioButton1.Checked Then Shell("shutdown -s -f -t " & TextBox1.Text & " -c " & TextBox2.Text)
        End If
0
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
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.