Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / December 2004

Tip: Looking for answers? Try searching our database.

Process.Start doesn't pick up new registry and environment variabl

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
James Li - 21 Dec 2004 00:49 GMT
I have the code below, I am spawning two process to run two external
programs, they need to be run in order.  the first one will install some
files and registry and environment variables, the second one will do
something else, assuming the registry and env vars are there.  

The problem is that the second process doesn't seem to be able to pick up
the registry and env vars done by the first process.  The makes me think the
new Process() is not that "NEW".  Any idea?

    executable = "setup_listener.bat";
    process1 = new Process();
    process1.StartInfo.UseShellExecute = false;
    process1.StartInfo.CreateNoWindow = false;
    process1.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
    process1.StartInfo.FileName = executable;
    //process1.StartInfo.RedirectStandardOutput = true;
    process1.Start();
    process1.WaitForExit();

    executable = "create_xdb_service.bat";
    process3 = new Process();
    process3.StartInfo.UseShellExecute = false;
    process3.StartInfo.CreateNoWindow = false;
    process3.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
    process3.StartInfo.FileName = executable;
    //process3.StartInfo.RedirectStandardOutput = true;
    process3.Start();
    process3.WaitForExit();
Steve Alpert - 21 Dec 2004 17:42 GMT
> I have the code below, I am spawning two process to run two external
> programs, they need to be run in order.  the first one will install some
[quoted text clipped - 24 lines]
>     process3.Start();
>     process3.WaitForExit();           

You can't get there from here.  Think of the execution environments
being inherited from the process that starts them.  A process gets a
copy of its parent environment and can then change it.  When it dies,
the changes die with it.

Setting registry keys should work.  Another "kludge" is to create an ini
file in process one and let process two read and then delete it.
Alternatively, why not let the first process continue into the second to
use the same environment?

/steveA

Signature

Steve Alpert
my email Fgrir_Nycreg @ vqk.pbz is encrypted with ROT13 (www.rot13.org)
and spaces

Ed Kaim - 23 Dec 2004 06:08 GMT
I believe ProcessStartInfo has an EnvironmentVariables property, which you
can use to set env for the second process. The trick will be to get the env
variables out of the first process, which might not be too hard if you can
hardcode or detect during execution. Otherwise, if you own the code from the
first bat, you can have the first process output them and read it from the
managing app by reading from Process.StartInfo.RedirectStandardOutput. It's
kind of a hack, but it works if you're just using it for internal stuff.

>> I have the code below, I am spawning two process to run two external
>> programs, they need to be run in order.  the first one will install some
[quoted text clipped - 33 lines]
>
> /steveA

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.