Trying to run a program using a Queue.

T

Ty Moffett

I am trying to write a little app that will perform unattended installations
of various software packages. I have a text file, each line is a string
containing the complete command to start a silent/unattended install. I
have successfully read the entire file and each line gets added to the
queue. On this line "myProcess.StartInfo.FileName(myQ.Dequeue)" i get an
error: C:\Documents and Settings\tmoffett\My Documents\Visual Studio
Projects\HandsOff\Module1.vb(36): Property access must assign to the
property or use its value.



Is there a better way to go about this?


Thanks in advance.





Imports Microsoft.Win32

Imports Microsoft.VisualBasic

Imports System.Collections

Imports System.IO

Imports System.Object

' Run the program

' read the first command from the queue

' run the command

' remove the item from the queue

' set automatic login information

' reboot

' rerun the program until the queue is empty

Module HandsOff

Public Sub main()

Dim fs As New FileStream("c:\HandsOff.txt", FileMode.OpenOrCreate)

Dim sr As New StreamReader(fs)

Dim line As String

line = sr.ReadLine()

Dim myQ As New Queue

Do Until line = Nothing

myQ.Enqueue(line)

line = sr.ReadLine

Loop

' Displays the properties and values of the Queue.

Console.WriteLine("myQ")

Console.WriteLine(ControlChars.Tab + "Count: {0}", myQ.Count)

Console.Write(ControlChars.Tab + "Values:")

PrintValues(myQ)

Do While myQ.Count > 0

Dim myProcess As New Process

myProcess.StartInfo.FileName(myQ.Dequeue)

myProcess.Start()

'Shell(myQ.Dequeue())

'Registry hacks to enable automatic logon upon reboot

AutoLogon()

'Registry hacks to enable this program to start upon logon.

RunOnce()

'Reboot the computer.

Shell("shutdown.exe -r -f -t 05")

Loop

'Registry hacks to disable automatic logon upon reboot.

UndoAutoLogon()

End Sub
 
F

Fergus Cooney

Hi Ty,

myProcess.StartInfo.FileName(myQ.Dequeue)

StartInfo.FileName is a Property as mentioned in the error message. This
means that its like a variable and must be used as such (use its value
somewhere or set it).

The line above is simlar to this:
Dim sYourName
sYourName ("Ty")

I'm sure, looking at this with an ordinary string, you can see that it's
wrong and should be:
sYourName = "Ty"

Simlarly you need:
myProcess.StartInfo.FileName = myQ.Dequeue

Regards,
Fergus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top