Berbeda dengan Plink, bitvise CMD ini kita langsung menggunakan program bitvise namun tidak seperti tunnel bitvise biasanya, disini Log dari bitvise itu akan kita program atau arahkan ke Memo di delphi, mirip-mirip plink lah.
Sedikit kekurangan den kelebihan nya.
Kekurangan
- Tidak bisa login SSH baru di bitvise CMD.
Kelebihan
- Simple dan lebih modern.
- Lebih hemat RAM.
- Tidak menuh-menuhin taksbar karna icon bitvise.
- Tidak ada Zlip seperti Plink.
copas funcion KillTask dibawah ini tepat dibawah {$R *.dfm}.
function KillTask(ExeFileName: string): Integer;
const
PROCESS_TERMINATE = $0001;
var
ContinueLoop: BOOL;
FSnapshotHandle: THandle;
FProcessEntry32: TProcessEntry32;
begin
Result := 0;
FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
FProcessEntry32.dwSize := SizeOf(FProcessEntry32);
ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
while Integer(ContinueLoop) <> 0 do
begin
if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) =
UpperCase(ExeFileName)) or (UpperCase(FProcessEntry32.szExeFile) =
UpperCase(ExeFileName))) then
Result := Integer(TerminateProcess(
OpenProcess(PROCESS_TERMINATE,
BOOL(0),
FProcessEntry32.th32ProcessID),
0));
ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
end;
CloseHandle(FSnapshotHandle);
end;
lalu copas/pasang uses di bawah ini tepat di bawah Implementation.uses ShellApi, TlHelp32;
Sekarang tambahkan komponen edit, button dll dan susun kira-kira seperti gambar di bawah ini.Jangan lupa juga tambahkan 3 komponen DosCommand dan memo yang nanti menjadi tempat LOG Bitvise nya. kemudian copas cooding ini di button button Connect yang kita buat tadi.
var
b_dir, b_cmd1, b_cmd2, b_cmd3 :String;
Pf, Pf_dir :String;
begin
pf := 'Bin\Proxifier\Proxifier.exe';
b_dir := ExtractFilePath(Application.Exename)+'Bin\Bitvise CMD\Bitvise.exe ';
b_cmd1 := Edit3.Text+'@'+Edit1.Text+':'+Edit2.Text+' -pw='+Edit4.Text+' -proxy=y -proxyType='+ComboBox1.Text+' -proxyServer='+Edit5.Text+' -proxyPort='+Edit6.Text+' -proxyFwding=y -proxyListIntf=127.0.0.1 -proxyListPort=1081';
b_cmd2 := Edit3.Text+'@'+Edit1.Text+':'+Edit2.Text+' -pw='+Edit4.Text+' -proxy=y -proxyType='+ComboBox1.Text+' -proxyServer='+Edit5.Text+' -proxyPort='+Edit6.Text+' -proxyFwding=y -proxyListIntf=127.0.0.1 -proxyListPort=1082';
b_cmd3 := Edit3.Text+'@'+Edit1.Text+':'+Edit2.Text+' -pw='+Edit4.Text+' -proxy=y -proxyType='+ComboBox1.Text+' -proxyServer='+Edit5.Text+' -proxyPort='+Edit6.Text+' -proxyFwding=y -proxyListIntf=127.0.0.1 -proxyListPort=1083';
//------------------------------------------------------------------------------
if Button1.Caption = 'Connect' then begin
Button1.Caption := 'Disconnect';
if ComboBox2.Text = '1x' then begin
DosCommand1.CommandLine := b_dir + b_cmd1;
DosCommand1.Execute;
Pf_dir:='Bin\Proxifier\Profile\Bitvise\Profile_1x.ppx silent-load';
Sleep(500);
shellexecute(handle,'open',pchar(Pf),pchar(Pf_dir),nil,sw_hide);
end else
if ComboBox2.Text = '2x' then begin
DosCommand1.CommandLine := b_dir + b_cmd1;
DosCommand2.CommandLine := b_dir + b_cmd2;
DosCommand1.Execute; Sleep(500);
DosCommand2.Execute;
Pf_dir:='Bin\Proxifier\Profile\Bitvise\Profile_2x.ppx silent-load';
Sleep(500);
shellexecute(handle,'open',pchar(Pf),pchar(Pf_dir),nil,sw_hide);
end else
if ComboBox2.Text = '3x' then begin
DosCommand1.CommandLine := b_dir + b_cmd1;
DosCommand2.CommandLine := b_dir + b_cmd2;
DosCommand3.CommandLine := b_dir + b_cmd3;
DosCommand1.Execute; Sleep(500);
DosCommand2.Execute; Sleep(500);
DosCommand3.Execute;
Pf_dir:='Bin\Proxifier\Profile\Bitvise\Profile_3x.ppx silent-load';
Sleep(500);
shellexecute(handle,'open',pchar(Pf),pchar(Pf_dir),nil,sw_hide);
end;
end else begin
Button1.Caption := 'Connect';
KillTask('Bitvise.exe');
KillTask('Proxifier.exe');
end;
lalu klik 2x masing masing DosCommand dan masukkan cooding ini.
var
cmd, dir: String;
begin
if (pos('error',NewLine)>0) or (pos('ERROR',NewLine)>0) then begin
dir := ExtractFilePath(Application.Exename)+'Bin\Bitvise CMD\Bitvise.exe';
cmd := Edit3.Text+'@'+Edit1.Text+':'+Edit2.Text+' -pw='+Edit4.Text+' -proxy=y -proxyType='+ComboBox1.Text+' -proxyServer='+Edit5.Text+' -proxyPort='+Edit6.Text+' -proxyFwding=y -proxyListIntf=127.0.0.1 -proxyListPort=1081';
DosCommand1.CommandLine := dir + cmd;
DosCommand1.Execute;
end;
memo1.Lines.Add(NewLine);
lakukan cara yang sama untuk DosCommand yang lain, dan bedakan pada text yang saya beri warna merah. Dos1 untuk 1081, Dos2 untuk 1082 dan seterusnya.Nah sekarang coba RUN Bitvise CMD kamu dan coba jalankan, dan jika berhasil akan jadi seperti ini.
Dan seperti biasa, untuk yang kesusahan saya sudah menyiapkan source codenya. untuk SourceCode nya bisa contact saya melalui Facebook atau Form E-Mail.
0 comments:
Post a Comment