I'm using a queue to hold a series of strings that are complete command line
arguments to start the silent/unattended installation of various pieces of
software. Here is some sample code.
1 Dim myProcess as New Process
2 myProcess.Enabl eRaiseEvents = True
3 myProcess.Start Info.Filename = myQ.Dequeue ' The string value in this
instance is "c:\windows XP-KB824146-x86-ENU.exe /u /n /z"
4 Do Until (myProcess.HasE xited = True)
5 Loop
6 AutoLogon() ' Sets various registry keys.
7 RunOnce() ' Sets some more registry keys.
8 Shell("shutdown .exe -r -f -t 05") ' Forces a reboot of the system in 5
seconds.
The problem is that on line 4 it throws an exception "No Process is
associated with this object".
The other problem is that if I take out the do loop entirely the .exe fires
off and begins installation but the program doesn't wait for it to finish.
It immediately move on to 6, 7, and worst of all 8. Then the system reboots
mid-installation.
Is there a good way to make the thing wait until the installation is done
before continuing on? I piddled with Process.ExitCod e as well with no luck.
Thanks in advance. =) 5 8088
I don't see myProcess.Start () anywhere. Looks like that's what you need.
Would be good also to throw in some Sleep() call inside loop.
HTH
Alex
"Ty Moffett" <tm******@solar c.com> wrote in message
news:eN******** ******@TK2MSFTN GP12.phx.gbl... I'm using a queue to hold a series of strings that are complete command
line arguments to start the silent/unattended installation of various pieces of software. Here is some sample code.
1 Dim myProcess as New Process 2 myProcess.Enabl eRaiseEvents = True 3 myProcess.Start Info.Filename = myQ.Dequeue ' The string value in this instance is "c:\windows XP-KB824146-x86-ENU.exe /u /n /z" 4 Do Until (myProcess.HasE xited = True) 5 Loop
6 AutoLogon() ' Sets various registry keys. 7 RunOnce() ' Sets some more registry keys. 8 Shell("shutdown .exe -r -f -t 05") ' Forces a reboot of the system in
5 seconds.
The problem is that on line 4 it throws an exception "No Process is associated with this object".
The other problem is that if I take out the do loop entirely the .exe
fires off and begins installation but the program doesn't wait for it to finish. It immediately move on to 6, 7, and worst of all 8. Then the system
reboots mid-installation.
Is there a good way to make the thing wait until the installation is done before continuing on? I piddled with Process.ExitCod e as well with no
luck.
Thanks in advance. =)
Hi Ty,
Still going for it. ;-)
If you have the filename and the arguments mixed,
myProcess.Start Info.Filename = myQ.Dequeue
where it's "c:\windows XP-KB824146-x86-ENU.exe /u /n /z",
it will look for a file called
"windowsXP-KB824146-x86-ENU.exe /u /n /z"
which it won't find, of course.
You need to separate the args out and have
myProcess.Start Info.Filename = <just the file path>
myProcess.Start Info.Arguments = <the arguments>
(as well as the Process.Start that Alex mentioned).
Regards,
Fergus
In article <eN************ **@TK2MSFTNGP12 .phx.gbl>, Ty Moffett wrote: I'm using a queue to hold a series of strings that are complete command line arguments to start the silent/unattended installation of various pieces of software. Here is some sample code.
1 Dim myProcess as New Process 2 myProcess.Enabl eRaiseEvents = True 3 myProcess.Start Info.Filename = myQ.Dequeue ' The string value in this instance is "c:\windows XP-KB824146-x86-ENU.exe /u /n /z" 4 Do Until (myProcess.HasE xited = True) 5 Loop
6 AutoLogon() ' Sets various registry keys. 7 RunOnce() ' Sets some more registry keys. 8 Shell("shutdown .exe -r -f -t 05") ' Forces a reboot of the system in 5 seconds.
The problem is that on line 4 it throws an exception "No Process is associated with this object".
The other problem is that if I take out the do loop entirely the .exe fires off and begins installation but the program doesn't wait for it to finish. It immediately move on to 6, 7, and worst of all 8. Then the system reboots mid-installation.
Is there a good way to make the thing wait until the installation is done before continuing on? I piddled with Process.ExitCod e as well with no luck.
Thanks in advance. =)
Here is a stupid little example....
Option Strict On
Option Explicit On
Imports System.Collecti ons
Imports System.Diagnost ics
Module Module1
Private Class Command
Public Sub New(ByVal cmd As String, ByVal args As String)
Me.cmd = cmd
Me.args = args
End Sub
Public cmd As String
Public args As String
End Class
Sub Main()
Dim cmds() As Command = {New Command("cmd", "/c dir c:\windows
/p"), New Command("cmd", "/k echo hello, world")}
Dim q As New Queue(cmds)
Dim cmd As Command
Dim p As Process
Do While q.Count > 0
cmd = DirectCast(q.De queue(), Command)
p = Process.Start(c md.cmd, cmd.args)
p.WaitForExit()
Loop
End Sub
End Module
HTH
--
Tom Shelton
MVP [Visual Basic]
Thank you both Gentlemen. I'll take yor advise and see what I can do.
Thanks again!
"Fergus Cooney" <fi*****@post.c om> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. .. Hi Ty,
Still going for it. ;-)
If you have the filename and the arguments mixed, myProcess.Start Info.Filename = myQ.Dequeue
where it's "c:\windows XP-KB824146-x86-ENU.exe /u /n /z", it will look for a file called "windowsXP-KB824146-x86-ENU.exe /u /n /z" which it won't find, of course.
You need to separate the args out and have myProcess.Start Info.Filename = <just the file path> myProcess.Start Info.Arguments = <the arguments>
(as well as the Process.Start that Alex mentioned).
Regards, Fergus
Ok, I'm now trying to use enumerator to put what is still in my queue into
the streamwriter so i can write it back to disk. I'm confused...this error
makes no sense to me. I'm sure I'm doing something dumb.
Do While myQ.GetEnumerat or.MoveNext
sw = myQ.GetEnumerat or.Current 'This line gets an exception: Enumeration
has not started. Call MoveNext.
Loop
Here is the main() code without the subroutines.
' 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.OpenOr Create,
FileAccess.Read Write)
Dim sr As New StreamReader(fs )
Dim sw As New StreamWriter(fs )
Dim line As String
line = sr.ReadLine()
Dim myQ As New Queue
Do Until line = Nothing
myQ.Enqueue(lin e)
line = sr.ReadLine
Loop
' Displays the properties and values of the Queue.
Console.WriteLi ne("myQ")
Console.WriteLi ne(ControlChars .Tab + "Count: {0}", myQ.Count)
Console.Write(C ontrolChars.Tab + "Values:")
PrintValues(myQ )
If myQ.Count > 0 Then
Dim myProcess As New Process
myProcess.Enabl eRaisingEvents = True
myProcess.Start Info.FileName = myQ.Dequeue
myProcess.Start Info.Arguments = myQ.Dequeue
'Write the remaining Queue members to the text file.
Do While myQ.GetEnumerat or.MoveNext
sw = myQ.GetEnumerat or.Current
Loop
'Start the process.
myProcess.Start ()
Do Until (myProcess.HasE xited = True)
Loop
'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")
End If
'Registry hacks to disable automatic logon upon reboot.
UndoAutoLogon()
End Sub This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: toby |
last post by:
Can any one help? I'm trying to use System.Diagnostics.Process.Start to open
legacy MS access aplications (ade and mdb files) and vb 6 .exe's using
asp.net. There is something confusing going on?!?
The files are all in the same network location, when I try and start the
MSaccess files I get a "file not found" error (it does go as far as opening
Msaccess, but doesn't load the DB), when I try to start the exe, the .exe is
found and runs, but...
|
by: Daniel Reber |
last post by:
I am trying to start a process from a windows service but when the process
starts the command window that the process runs in never shows. Is this
because I am calling it from a windows service? Is there something else
that I need to do?
Here is my code:
System.Diagnostics.ProcessStartInfo info = new
System.Diagnostics.ProcessStartInfo();
|
by: ginee lee via .NET 247 |
last post by:
(Type your message here)
hi all,
It seems that the arguments of System.Diagnostics.Process.Start()can only be the absolute path. The args can not be like".\abc\efg.exe" or "..\abc\efg.exe". While i use relative path,the function doesn't work. Any solution??
The other question is... i take a example fisrt!
System.Diagnostics.Process.Start("c:\\abc.exe", "hello.txt"); itworks fine. BUT if the second arg replace with "helloworld.exe",...
|
by: andreas |
last post by:
hi,
In windows xp in the start launch menu when i put
notepad "c:\test.txt"
i get notepad with test.txt in it.
in vb.net when i state
system.diagnostics.process.start("notepad.exe"
i get notepad
but
|
by: Daniel |
last post by:
System.Diagnostics.Process.Start fails on windows server 2003
the process returns process.ExitCode == 0 but executing any process with
System.Diagnostics.Process.Start on windows xp works fine.
anything to do different for windows server 2003? some special permission
for the process that executes another executable with
System.Diagnostics.Process.Start ??
here is the code:
| |
by: Daniel |
last post by:
what permissions does a windows service need to execute another process?
System.Diagnostics.Process process = System.Diagnostics.Process.Start(info);
just local administrator? any specific permitions?
|
by: Daniel |
last post by:
C# windows service freezes on System.Diagnostics.Process.Start(info)
When I launch PSCP from a C# windows service and launch pscp 0.53 there are
no issues. but when I use C# windows service to launch pscp 0.58 C# freezes
in System.Diagnostics.Process.Start(info)? pscp 0.58 works fine at command
line, but causes C# to freeze on ystem.Diagnostics.Process.Start(info) also
i noticed that the pscp process does not show in taske manager while...
|
by: Colin Williams |
last post by:
I am using the code below to map network drive and then fire up an app
in a sub dir of that drive. However when using the file open dialog
from that app, drive K: appears just as Network drive K: (this could
confuse users) rather than showing the path it is mapped to like in
explorer.
Using a batch file to execute these commands works great. Any ideas?
System.Diagnostics.Process.Start("net.exe", "use K:...
|
by: kimiraikkonen |
last post by:
Hello,
I want to ask this:
If i do: System.Diagnostics.Process.Start("c:\lame", "--preset
standard c:\blabla.wav c:\blabla.mp3") it works.
But i don't want this. I want my 2 textboxes must take place as
variable like: System.Diagnostics.Process.Start("c:\lame", "--preset
standard textbox1" textbox1.text +
textbox2.text). But that doesn't work. Meanwhile textboxes are the
|
by: KodeKrazy |
last post by:
I can use System.Diagnostics.Process.Start to launch .txt, .bmp, .jpg, etc., but if I try to launch an .exe, from the same folder, I get the "The system cannot find the file specified." error.
For example:
This works: System.Diagnostics.Process.Start("C:\swr\test.txt")
This does NOT: System.Diagnostics.Process.Start("C:\swr\engine.exe")
Any help is greatly appreciated!
KK
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |