R
R V Prasad
Guest
I have written below piece of code to achieve my task of exporting printers details on the machine. Below code works without any issues.
Generally, it takes a few seconds or more to generate the printer details file, hence I would like to display the status of this process on a label or text box (like "File is being generated. Please wait..", "File is generated.." etc.)
I'm unable to get the right status on the label with below code. It directly shows the "File is generated" status. But if put messagebox before and after while loop then it works fine.
Any assistance is greatly helpful. Thank you.
Label1.Text = "Status: File is being generated. Please wait.."
Dim pPrintBrm As New ProcessStartInfo
pPrintBrm.FileName = "C:\Windows\System32\spool\tools\PrintBrm.exe"
pPrintBrm.Arguments = " " & "-B" & " " & "-F" & " " &
My.Computer.FileSystem.CurrentDirectory & "\Extracted\Printer.PrinterExport"
pPrintBrm.WindowStyle = ProcessWindowStyle.Hidden
Process.Start(pPrintBrm)
Dim exists As Boolean = File.Exists(My.Computer.FileSystem.CurrentDirectory & "\Extracted\Printer.PrinterExport")
MessageBox.Show("before while " & exists)
While (exists = "False")
exists = File.Exists(My.Computer.FileSystem.CurrentDirectory & "\Extracted\Printer.PrinterExport")
End While
MessageBox.Show("after while " & exists)
If File.Exists(My.Computer.FileSystem.CurrentDirectory & "\Extracted\Printer.PrinterExport") Then
Label1.Text = "Status: File is generated"
Else
Label1.Text = "Status: Failed"
End If
Continue reading...
Generally, it takes a few seconds or more to generate the printer details file, hence I would like to display the status of this process on a label or text box (like "File is being generated. Please wait..", "File is generated.." etc.)
I'm unable to get the right status on the label with below code. It directly shows the "File is generated" status. But if put messagebox before and after while loop then it works fine.
Any assistance is greatly helpful. Thank you.
Label1.Text = "Status: File is being generated. Please wait.."
Dim pPrintBrm As New ProcessStartInfo
pPrintBrm.FileName = "C:\Windows\System32\spool\tools\PrintBrm.exe"
pPrintBrm.Arguments = " " & "-B" & " " & "-F" & " " &
My.Computer.FileSystem.CurrentDirectory & "\Extracted\Printer.PrinterExport"
pPrintBrm.WindowStyle = ProcessWindowStyle.Hidden
Process.Start(pPrintBrm)
Dim exists As Boolean = File.Exists(My.Computer.FileSystem.CurrentDirectory & "\Extracted\Printer.PrinterExport")
MessageBox.Show("before while " & exists)
While (exists = "False")
exists = File.Exists(My.Computer.FileSystem.CurrentDirectory & "\Extracted\Printer.PrinterExport")
End While
MessageBox.Show("after while " & exists)
If File.Exists(My.Computer.FileSystem.CurrentDirectory & "\Extracted\Printer.PrinterExport") Then
Label1.Text = "Status: File is generated"
Else
Label1.Text = "Status: Failed"
End If
Continue reading...