2014-08-27 46 views
0

事情是:我有兩個簡單的程序(同一軟件的x86和x64版本),我從互聯網下載。我想爲他們創建一個CD安裝程序。如何創建一個簡單的安裝程序調用程序

我只需要一個小而簡單的程序,從軟件文件夾「調用」setup.exe。一個帶有兩個按鈕的簡單窗口:「安裝x86版本」和「安裝x64版本」。比我可以點擊其中一個按鈕,程序會從右邊的文件夾調用setup.exe,然後關閉它自己。

這樣我就可以有這樣的結構,我的CD內頁:

./setup.exe 
./x64/setup.exe 
./x86/setup.exe 

事情是,我不知道如何寫這個簡單的軟件。我有Python的知識,但要安裝一個完整的Python解釋器只是打開一個兩個按鈕的小窗口是相當矯枉過正。

是否有一個簡單的腳本(在VB中,我猜)可以爲我做這個?我在curses for linux中寫了這樣的東西,但我不是Windows高級用戶。

非常感謝!

回答

2

在Visual Studio Express中創建一個新的WinForms應用程序並拖動窗體上的兩個按鈕。按你喜歡的設計。雙擊每個按鈕以編輯.Click事件。

的方法來啓動一個新的Windows進程Process.Start()

Private Sub Button1_Click(sender as Object, e as EventArgs) Handles Button1.Click 
    RunAndClose(IO.Path.Combine(Application.StartupPath, "x86", "setup.exe")) 
End Sub 
Private Sub Button2_Click(sender as Object, e as EventArgs) Handles Button2.Click 
    RunAndClose(IO.Path.Combine(Application.StartupPath, "x64", "setup.exe")) 
End Sub 

Private Sub RunAndClose(filename As String) 
    If IO.File.Exists(filename) = False Then 
    MessageBox.Show(String.Format("The selected installer {0}{0}{1}{0}{0} could not be found!", vbCrLf, filename), "Installer not found", MessageBoxButtons.OK, MessageBoxIcon.Error) 
    Else 
    Process.Start(filename) 
    Me.Close 
    End If 
End Sub 

您創建一個子RunAndClose實際做的工作。您有文件名作爲子參數。檢查您要啓動的文件是否存在(IO.File.Exists)。如果是這樣,啓動它並關閉應用程序,如果不顯示錯誤消息。

Button-Subs使用IO.Path.Combine函數。你提供了幾個零件,並從中建立了一條路徑。你想用它來代替手工建立字符串。

相關問題