Home  |  FAQ  |  About  |  Contact  |  View Source   
 
SEARCH:
 
BROWSE:
    My Hood
Edit My Info
View Events
Read Tutorials
Training Modules
View Presentations
Download Tools
Scan News
Get Jobs
Message Forums
School Forums
Member Directory
   
CONTRIBUTE:
    Sign me up!
Post an Event
Submit Tutorials
Upload Tools
Link News
Post Jobs
   
   
Home >  Messages >  C# >  Drive Mapping
Add to MyHood

Author
Subject:  Drive Mapping
 

Subscribe to this thread

Nadin  Merali

2/7/2003 9:56:44 AM Not rated

using c#

how would I find out what drive mappings a user has in NT4/2000 and how can I create them?


[Top]  [Bottom]  [Listen]  [Edit]  [Reply

Paul  Bastide

2/7/2003 5:15:53 PM Not rated

i would use a process creation in the System.Diagnostics

*someone correct me I can't remember the exact location

create a background cmd

cmd /s net view

cmd /s net send

cmd /s net use <driveletter>: \\location\sharename

try stuff like that, and it works.

-Paul



[Top]  [Bottom]  [Listen]  [Edit]  [Reply

Eli  Allen

2/7/2003 11:46:49 PM Not rated

don't use cmd as you can redirect the output so it makes it a bit easier.


[Top]  [Bottom]  [Listen]  [Edit]  [Reply

Nadin  Merali

2/10/2003 10:48:27 AM Not rated

What do you mean redirect.


Also is there no better way to do this without using a cmd? Does .NET not have a class or something thant can do this for me?



[Top]  [Bottom]  [Listen]  [Edit]  [Reply

Eli  Allen

2/12/2003 12:13:48 PM Not rated

public string MapDrive(string hostName,string path)
{
    string driveLet="";
    if(NotBlank(hostName))
    {
        System.Diagnostics.Process tmp=new System.Diagnostics.Process();
            
        System.Diagnostics.ProcessStartInfo tmp2=new 
            System.Diagnostics.ProcessStartInfo(
            "net","use * \\\\" + hostName + "\\" + path);
        tmp2.UseShellExecute=false;
        tmp2.RedirectStandardOutput=true;
        tmp2.CreateNoWindow=true;
    
        tmp=System.Diagnostics.Process.Start(tmp2); 
        string strOut=tmp.StandardOutput.ReadToEnd();
            
        tmp.WaitForExit();
            
        Regex re= new Regex(@"Drive\s(?<drive>[A-Z])(:)");
        Match m = re.Match(strOut);
        if (m.Success)
        {
            driveLet= m.Groups["drive"].Value;
        }
        else
        {
            MessageBox.Show(strOut);
                    
        }    
    }
    return driveLet;
}


Thats how to create. I'm sure you get the idea


Last Edited: 2/12/2003 12:16 PM EST [Top]  [Bottom]  [Listen]  [Edit]  [Reply

| | Last

Subscribe to this thread
Copyright © 2001 DevHood® All Rights Reserved