Jump to content
Sign in to follow this  
tron

adding browse gui and select txt file

Recommended Posts

tron

hi this is my first attempt at autoit .

my first script is very simple

RunWait('"' & @ComSpec & '" /c psexec @c:\WINDOWS\install\test.txt -c -i C:\WINDOWS\install\vlc.exe ', '', @SW_HIDE)

it starts the installer of vlc on the computers listed in the text file test.txt.

basicly what i want to do now is instead of only installing vlc add a browse to file (for installing), and browse for a txt file depending on the room for deployment. i also want to run these programs with there silent switches, anyone have any suggestions.

cheers

Share this post


Link to post
Share on other sites
Fire

Welcome To Autoit Forum tron.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Local $textfilepath,$vlcpath
#Region ### START Koda GUI section ### Form=Form1.kxf
$Form1 = GUICreate("Connect", 404, 195, 206, 126)
$filemenu=GUICtrlCreateMenu("File")
GUICtrlCreateMenuItem("",$filemenu)
$hfilemenuitem1vls=GUICtrlCreateMenuItem("Choose Your VLC...",$filemenu)
GUICtrlCreateMenuItem("",$filemenu)

$menuitem2textfile=GUICtrlCreateMenuItem("Open Your Text File...",$filemenu)
GUICtrlCreateMenuItem("",$filemenu)
$exititem=GUICtrlCreateMenuItem("Exit...",$filemenu)
GUICtrlCreateMenuItem("",$filemenu)
$Button1 = GUICtrlCreateButton("Run", 120, 128, 129, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hfilemenuitem1vls
            $hopenvlc=FileOpenDialog("Choose Your VLC File",@WindowsDir&"\install","Exe Files (*.exe)")
            $vlcpath=FileGetLongName($hopenvlc)
            ;MsgBox(64,"",$vlcpath)

        Case $menuitem2textfile
            $textfile=FileOpenDialog("Choose Your Text File",@WindowsDir&"\install","Text Files (*.txt)")
            $textfilepath=FileGetLongName($textfile)
            ;MsgBox(64,"",$textfilepath)
        Case $Button1
            If $vlcpath="" Then
                check()

        EndIf
        If $textfilepath="" Then
            second()
            Else
            ;RunWait('"' & @ComSpec & '" /c psexec @c:\WINDOWS\install\test.txt -c -i C:\WINDOWS\install\vlc.exe ', '', @SW_HIDE)
            RunWait("cmd.exe /c " & "psexec " & ""& $textfilepath &"" & " -c -i " & "" & $vlcpath & "",@ScriptDir,@SW_HIDE)
            MsgBox(64,"Operation Done","Operation Done",5)
        EndIf
    Case $exititem
        ExitLoop
    EndSwitch
WEnd


Func check()
MsgBox(64,"VLC NOT SELECTED!"   ,"VLC NOT SELECTED!",4)
EndFunc

Func second()
MsgBox(64,"TEXT FILE NOT SELECTED!","TEXT FILE NOT SELECTED!",4)
EndFunc

[size="5"] [/size]

Share this post


Link to post
Share on other sites
tron

wow that's quick !

and yes that's exactly what i was looking for but the script doesn't run the program out? there's no error's . operation done jumps up as soon as you hit run. also to add more to this i wanted to be able to add the silent switch in. depending on the program to be installed.

Sh3llC043r you are a true legend cheers

Share this post


Link to post
Share on other sites
Fire

Hi Tron.

If i understand correct it didnt work or ?

Also i add to it psexec choose option.

So, choose all correct components from File menu and then try run it.

+Would be super if you stay with us and try learn Autoit.

Sorry for my awfull English.(not native)

Here is:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Local $textfilepath,$vlcpath,$pathforpsexec
#Region ### START Koda GUI section ### Form=Form1.kxf
$Form1 = GUICreate("Connect", 404, 195, 206, 126)
$filemenu=GUICtrlCreateMenu("File")
GUICtrlCreateMenuItem("",$filemenu)
$hfilemenuitem1vls=GUICtrlCreateMenuItem("Choose Your VLC...",$filemenu)
GUICtrlCreateMenuItem("",$filemenu)
$psexecpath=GUICtrlCreateMenuItem("Choose PsExec Binary ...",$filemenu)
GUICtrlCreateMenuItem("",$filemenu)
$menuitem2textfile=GUICtrlCreateMenuItem("Open Your Text File...",$filemenu)
GUICtrlCreateMenuItem("",$filemenu)
$exititem=GUICtrlCreateMenuItem("Exit...",$filemenu)
GUICtrlCreateMenuItem("",$filemenu)
$Button1 = GUICtrlCreateButton("Run", 120, 128, 129, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
        Case $psexecpath
            $pseexecpath=FileOpenDialog("Choose Your Psexec Binary...",@ScriptDir,"Exe File (*.exe) ")
            $pathforpsexec=FileGetLongName($pseexecpath)
            MsgBox(64,"",$pathforpsexec)

    Case $hfilemenuitem1vls
    $hopenvlc=FileOpenDialog("Choose Your VLC File",@WindowsDir&"\install","Exe Files (*.exe)")
    $vlcpath=FileGetLongName($hopenvlc)
    ;MsgBox(64,"",$vlcpath)

    Case $menuitem2textfile
    $textfile=FileOpenDialog("Choose Your Text File",@WindowsDir&"\install","Text Files (*.txt)")
    $textfilepath=FileGetLongName($textfile)
    ;MsgBox(64,"",$textfilepath)
    Case $Button1
            If $pathforpsexec="" Then
                psexecnotfound()
                EndIf

    If $vlcpath="" Then
    check()

    EndIf
    If $textfilepath="" Then
    second()
    Else
    ;RunWait('"' & @ComSpec & '" /c psexec @c:\WINDOWS\install\test.txt -c -i C:\WINDOWS\install\vlc.exe ', '', @SW_HIDE)
    RunWait("cmd.exe /c " & """" & $pathforpsexec & """" & " " &""""& $textfilepath &"""" & " -c -i " & """" & $vlcpath & """",@ScriptDir,@SW_HIDE)
            ;
            ;MsgBox(64,"","""" & $pathforpsexec & """" & " " &""""& $textfilepath &"""" & " -c -i " & """" & $vlcpath & """")
    MsgBox(64,"Operation was Done","Operation was Done",5)
    EndIf
    Case $exititem
    ExitLoop
    EndSwitch
WEnd


Func check()
MsgBox(64,"VLC NOT SELECTED!" ,"VLC NOT SELECTED!",4)
EndFunc

Func second()
MsgBox(64,"TEXT FILE NOT SELECTED!","TEXT FILE NOT SELECTED!",4)
EndFunc

Func psexecnotfound()
    MsgBox(64,"Choose Your Psexec","Choose Your Psexec",4)
    EndFunc

[size="5"] [/size]

Share this post


Link to post
Share on other sites
tron

its not giving me an error , but its not running the installer on the remote machine. i don't need to select psexec.exe so the first script was fine its just not connecting to the remote machine.

RunWait('"' & @ComSpec & '" /c psexec @c:\WINDOWS\install\test.txt -c -i C:\WINDOWS\install\vlc.exe /s ', '', @SW_HIDE)

this would install vlc with a silent switch (/s)

couldn't we just take out @c:\WINDOWS\install\test.txt and C:\WINDOWS\install\vlc.exe and add the browse options in?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.