Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: C# Pulling Process ID
07-07-2008, 03:51 PM #1
- Join Date
- Sep 2006
- Thanked 0 Times in 0 Posts
C# Pulling Process ID
I have a log on script to launch an application. Mostly it maps network drives on the local computer that are hard coded into the application (IE The application was not designed for a network based install).
I want to build a *.exe that reads from a SQL Database for permissions for a given user. (IE: The application development team needs to have the testing environment mapped).
Currently, I have a *.bat file searches a network folder using the IF EXISIT function. If there is a file in that folder named by the user's login ID, then they extra drive is mapped. If there is not one, then the extra drive is not mapped.
In the batch script I call the NET USE function.
1. First I delete the old drive mapping.
2. Then I map that drive letter to the correct location.
I have the C# code working. My problem is that is runs the code to quickly. The old drive does not completely unmap prior to the new mapping command being executed causing Windows Explorer to do weird things (It shows that it is still mapped to the old location, or when the other command is completed it doesn’t show at all, until I call it in the address bar).
This code using the System.Diagnostics
//Delete Old Drive Mappings Process.Start(@"C:/WINDOWS/System32/net.exe", @"use "+driveLetter+" /delete"); //Map Drives Process.Start(@"C:/WINDOWS/System32/net.exe", @"use "+driveLetter+" "+networkLocation);
I am not sure how to obtain the process ID for the process that just started.
07-07-2008, 04:35 PM #2
- Join Date
- Sep 2004
- Thanked 40 Times in 40 Posts