Topic: Help with a Script

Hi All,

I need help with the following action for a button.  When click I want to map a network drive using parameters from user's input boxes, the following code doesn't give me any error but does not map the drive sad     

thanks in advance!

procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
var
User: string;
Pass: string;
begin
    User := Form1.edUser.Text;
    Pass := Form1.edPass.Text;

    OpenFile('net use U: \\DC-1\UsersHome$\"User" /u:,"User" "Pass" net.exe');
end;


begin
 Form1.mniFile.Visible := False;
 Form1.mniOptions.Visible := False;
 Form1.mniSettings.Visible := False;
 Form1.mniReport.Visible := False;
 Form1.mniAbout.Visible := False;
end.

Re: Help with a Script

OpenFile('net use U: \\DC-1\UsersHome$\"'+User+'" /u:,"'+User+'" "Pass" net.exe');
Dmitry.

Re: Help with a Script

DriveSoft wrote:
OpenFile('net use U: \\DC-1\UsersHome$\"'+User+'" /u:,"'+User+'" "Pass" net.exe');

Hi Dmitry,


thanks for the quick answer,  unfortunately that still didn't work  sad

It's not mapping the network drive.

Re: Help with a Script

Unfortunately I don't know how to map a network drive, but try this:

OpenFile('use U: \\DC-1\UsersHome$\"'+User+'" /u:,"'+User+'" "Pass"', 'net');
Dmitry.

Re: Help with a Script

DriveSoft wrote:

Unfortunately I don't know how to map a network drive, but try this:

OpenFile('use U: \\DC-1\UsersHome$\"'+User+'" /u:,"'+User+'" "Pass"', 'net');

Thank you, I tried it that way too and still couldn't map the drive.  Finally what I did was kind of a crazy detour and probably more work
than needed to make it work but it's working for me without any problems.  Here's the code:

var
ini:TIniFile;


procedure Form1_edUser_OnChange (Sender: TObject);
begin
  ini:=TIniFile.Create(ExtractFilePath (ParamStr (0))+'info.ini');
  ini.WriteString('INFO','USER',Form1.edUser.Text);
end;
procedure Form1_edPass_OnChange (Sender: TObject);
begin
  ini:=TIniFile.Create(ExtractFilePath (ParamStr (0))+'info.ini');
  ini.WriteString('INFO','PASS',Form1.edPass.Text);
end;


procedure Form1_OnShow (Sender: TObject; Action: string);
begin
    Form1.edUser.SetFocus;
end;

procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
begin

       OpenFile('connect.cmd.lnk');
       application.processmessages;
       sleep(600);
       Form1.edStatus.Visible := TRUE;

end;

I'm creating a .INI file, saving the information from the user's input in the form to this INI file, then having a batch file read the contents of
the INI file and executing the mapping.