I posted a few ago but didn't see it show up... so if i'm just waiting approval or something can delete this one.
I"ve been working on a project for a couple of days now and it's driving me insane.
I have to find out if windows features are installed
If the yare not installed install them
I'm able to tell if they are installed just fine i'm having an issue with installing them.
Here's my code
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Button1.Enabled = False
TextBox2.Text = "Checking Features" & vbNewLine
Dim DisabledAnswer As Boolean = Nothing
Dim SuccessInstall As Boolean = Nothing
DisabledAnswer = isDisabled("WCF-HTTP-Activation45", " /online /Get-FeatureInfo /FeatureName:", "State : Disabled")
TextBox2.Text = TextBox2.Text & "WCF-HTTP-Activation45 Disabled status is " & DisabledAnswer & vbNewLine
If DisabledAnswer = True Then
TextBox2.Text = TextBox2.Text & "Installing WCF-HTTP-Activation45" & vbNewLine
SuccessInstall = isDisabled("WCF-HTTP-Activation45", " /online /Enable-Feature /all /FeatureName:", "The operation completed successfully.")
TextBox2.Text = TextBox2.Text & "WCF-HTTP-ACtivation45 was successful " & SuccessInstall & vbNewLine
Else
TextBox2.Text = TextBox2.Text & "WCF-HTTP-Activation45 was skipped" & vbNewLine
End If
DisabledAnswer = Nothing
SuccessInstall = Nothing
DisabledAnswer = isDisabled("WCF-TCP-Activation45", " /online /Get-FeatureInfo /FeatureName:", "State : Disabled")
TextBox2.Text = TextBox2.Text & "WCF-TCP-Activation45 Disabled status is " & DisabledAnswer & vbNewLine
If DisabledAnswer = True Then
TextBox2.Text = TextBox2.Text & "Installing WCF-TCP-Activation45" & vbNewLine
SuccessInstall = isDisabled("WCF-TCP-Activation45", " /online /Enable-Feature /all /FeatureName:", "The operation completed successfully.")
TextBox2.Text = TextBox2.Text & "WCF-TCP-Activation45 was successful " & SuccessInstall & vbNewLine
Else
TextBox2.Text = TextBox2.Text & "WCF-TCP-Activation45 was skipped" & vbNewLine
End If
DisabledAnswer = Nothing
SuccessInstall = Nothing
DisabledAnswer = isDisabled("WCF-Pipe-Activation45", " /online /Get-FeatureInfo /FeatureName:", "State : Disabled")
TextBox2.Text = TextBox2.Text & "WCF-Pipe-Activation45 Disabled status is " & DisabledAnswer & vbNewLine
If DisabledAnswer = True Then
TextBox2.Text = TextBox2.Text & "Installing WCF-Pipe-Activation45" & vbNewLine
SuccessInstall = isDisabled("WCF-Pipe-Activation45", " /online /Enable-Feature /all /FeatureName:", "The operation completed successfully.")
TextBox2.Text = TextBox2.Text & "WCF-Pipe-Activation45 was successful " & SuccessInstall & vbNewLine
Else
TextBox2.Text = TextBox2.Text & "WCF-Pipe-Activation45 was skipped" & vbNewLine
End If
DisabledAnswer = Nothing
SuccessInstall = Nothing
TextBox2.Text = TextBox2.Text & "Finished" & vbNewLine
Button1.Enabled = True
End Sub
Code:
Private Function isDisabled(ByVal varName As String, ByVal varString As String, ByVal varLookingFor As String)
varPublicvarName = varName
If My.Computer.FileSystem.FileExists(varName) Then
My.Computer.FileSystem.DeleteFile(varName)
Else
' MsgBox("Doesn't")
End If
Dim proc As ProcessStartInfo = New ProcessStartInfo
Dim pr As Process
proc.FileName = "cmd"
proc.CreateNoWindow = False
proc.UseShellExecute = False
proc.RedirectStandardInput = True
proc.RedirectStandardOutput = True
pr = Process.Start(proc)
pr.StandardInput.WriteLine("Dism>>" & varName & varString & varName)
pr.StandardInput.WriteLine("Exit")
pr.StandardInput.Close()
pr.WaitForExit()
If TextBox1.Text.Contains(varLookingFor) Then
My.Computer.FileSystem.DeleteFile(varName)
Return False
Else
My.Computer.FileSystem.DeleteFile(varName)
Return True
End If
End Function
My issue is sometimes it prompts for a restart so the command window never closes and I can't read the text that's asking for it to restart. that's why I have it writing to a document.
I can open the document up in notepad and it's asking if I want to restart yes/no.
my question is is their a way I can send something along with the original info that answers that question.
if I could hit no then it would close the window and continue onto the next one, "If I open taskmanager and kill the process" that's what it does. I can't read the document in my program it tells me that it's in use and throws an error.
Any help would be appreciated.