Jump to content

Installation


Recommended Posts

I'm still a novice with AutoIT, but I'm trying to use it more whenever I have a chance, and still trying to figure things out.

I know that to run certain 'items' you have to supply the application that will kick it off.

I've been successful in kicking off a VBScript like so:

RUNWAIT( "wscript.exe C:\Scripting\myScript.vbs" )

Also an HTA:

RUNWAIT( "mshta.exe C:\Scripting\myHTA.hta" )

Now I'm stuck at trying to run an Executible that was created through Wise Packaging.

Has anyone attempted this before, or can give me some pointers in putting this together?

The individual at my work, that puts these packages together, states that they are kicked off by an application called WiFI.exe; he really didn't seem sure about that, so I'm stuck on trying to figure this out. (Yes, I attempted to run them with the 'WiFI.exe' but AutoIT had troubles with it: Unable to execute the external program)

Here is the script that I created; there are a couple of files that it reads from to extract the Admin Password and the package to install.

All of that works fine, the only problem I have is launching the Wise EXE.

I was able to create a vbscript to launch the exe, and call that script from within the AutoIT script, but I want to be able to do all of this from within the AutoIT.

CODE

$sProgram = "\\<server>\<share>\Automate_Installs\Install.ini" ;Path to the installation package on network

$sFile = "\\<server>\<share>\Automate_Installs\Creds.ini" ;Path to the Admin Password file

$sScript = "\\<server>\<share>\Automate_Installs\RunInstallation.vbs " ;Path to VBScript to run desired installation

$sAccount = "Administrator"

$sMachine = @ComputerName

IF NOT FileExists( $sFile ) THEN ;Unable to locate the Admin Password File

MSGBOX(16,"Password Required","Unable to verify credentials! - Contact Help Desk")

Exit

ENDIF

IF NOT FileExists( $sProgram ) THEN

MSGBOX(16,"Install Program Required","Unable to determine the installation requested - Contact Help Desk")

Exit

ENDIF

$sPassword = FileReadLine( $sFile )

$sInstall = FileReadLine( $sProgram )

$array = StringSplit( $sInstall,";" ) ;1 = variable for package, 2 = path to EXE

; MSGBOX(64,"Information passed:",$sAccount & " " & $sMachine & " " & $sPassword) ;Used in testing purposes only

RunAsSet($sAccount,$sMachine,$sPassword) ;Runs this portion as local admin

RUNWAIT( $array[2] )

;RUNWAIT( "wscript.exe " & $sScript & $array[2] ) ;This line works, but I don't want to use vbscript

RunAsSet() ;Returns everything back to normal

Exit

Any ideas/suggestions?

Any help is appreciated.

If you try to fail and succeed which have you done?AutoIt Forum Search

Link to comment
Share on other sites

the file must exist ( i can't see what is in your Programs ini file)

example

Dim $array[3]
$array[2] = @SystemDir & "\notepad.exe"
If FileExists($array[2]) Then RUNWAIT( FileGetShortName($array[2]) )
Sleep(3000)
Exit

8)

OK, can you explain a little bit on this, so that I don't feel like such a schmuck! :">

If I do not include the "IF FileExists( $array[2] )" then it won't run; once I included that line it ran like it's supposed to.

Doesn't make any freakin sense... :whistle:

CODE

IF FileExists( $array[2] ) THEN

RUNWAIT( $array[2] )

ELSE

MSGBOX(16,"ERROR","Unable to locate application")

ENDIF

If you try to fail and succeed which have you done?AutoIt Forum Search

Link to comment
Share on other sites

OK, can you explain a little bit on this, so that I don't feel like such a schmuck! :

If I do not include the "IF FileExists( $array[2] )" then it won't run; once I included that line it ran like it's supposed to.

Doesn't make any freakin sense... :whistle:

CODE

IF FileExists( $array[2] ) THEN

RUNWAIT( $array[2] )

ELSE

MSGBOX(16,"ERROR","Unable to locate application")

ENDIF

LOL...

I dunno... it works, so use it

( normally Filegetshortname() helps)

8)

NEWHeader1.png

Link to comment
Share on other sites

LOL...

I dunno... it works, so use it

( normally Filegetshortname() helps)

8)

I appreciate your assistance on this, but I'm just trying to wrap my head around this since I'm trying to work with AutoIT more.

Example that does work in AutoIT: RunWait( "wscript.exe c:\test\myScript.vbs" )

Example that doesn't work in AutoIT: RunWait( "c:\test\myApplication.exe" )

Will work if I write it like this:

IF FileExists( "c:\test\myApplication.exe" ) THEN

RunWait( "c:\test\myApplication.exe")

ENDIF

So why don't I have to write my first example like this:

IF FileExists( "c:\test\myScript.vbs" ) THEN

RunWait( "wscript.exe c:\test\myScript.vbs" )

ENDIF

Just looking for some sort of consistency.

Anyone able to give a little insight to this?!?

By the way, Valuater, thanks. :whistle:

If you try to fail and succeed which have you done?AutoIt Forum Search

Link to comment
Share on other sites

  • Moderators

I always write all of my conditions like that... no sense in throwing an error if you can avoid it 1 or 2 extra lines.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I always write all of my conditions like that... no sense in throwing an error if you can avoid it 1 or 2 extra lines.

So, no real explanation as to why it will run without the "FileExists" some times and other times it will require the "FileExists" method?

Just trying to educate myself on this; I understand the reasoning behind adding the extra bit of code (and I have no problem using that in any code from here forward), but I don't understand why it's not consistent.

If you try to fail and succeed which have you done?AutoIt Forum Search

Link to comment
Share on other sites

  • Moderators

So, no real explanation as to why it will run without the "FileExists" some times and other times it will require the "FileExists" method?

Just trying to educate myself on this; I understand the reasoning behind adding the extra bit of code (and I have no problem using that in any code from here forward), but I don't understand why it's not consistent.

If the file exists and it runs, it would run without that period. You must be changing conditions, such as, you might be using a variable or macro for the Run() parameter. If there are spaces in the path, then it could fail sometimes if not always. That's why Valuater used FileGetShortName().

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

If the file exists and it runs, it would run without that period. You must be changing conditions, such as, you might be using a variable or macro for the Run() parameter. If there are spaces in the path, then it could fail sometimes if not always. That's why Valuater used FileGetShortName().

But that's what has me baffled, I'm not changing anything.

$sProgram = "C:\test\myApplication.exe"

$sScript = "C:\test\myScript.vbs"

RUNWAIT( $sProgram ) ; will not run

RUNWAIT( "wscript.exe " & $sScript ) ; will run fine

IF FileExists( $sProgram ) THEN

RUNWAIT( $sProgram ) ; will run fine

ENDIF

IF FileExists( $sScript ) THEN

RUNWAIT( "wscript.exe " & $sScript ) ; will also run fine

ENDIF

In both instances, using 'FileExists' and not using 'FileExists, $sProgram does not change.

So why won't it run if you first don't check with 'FileExists'?

If you try to fail and succeed which have you done?AutoIt Forum Search

Link to comment
Share on other sites

  • Moderators

But that's what has me baffled, I'm not changing anything.

$sProgram = "C:\test\myApplication.exe"

$sScript = "C:\test\myScript.vbs"

RUNWAIT( $sProgram ) ; will not run

RUNWAIT( "wscript.exe " & $sScript ) ; will run fine

IF FileExists( $sProgram ) THEN

RUNWAIT( $sProgram ) ; will run fine

ENDIF

IF FileExists( $sScript ) THEN

RUNWAIT( "wscript.exe " & $sScript ) ; will also run fine

ENDIF

In both instances, using 'FileExists' and not using 'FileExists, $sProgram does not change.

So why won't it run if you first don't check with 'FileExists'?

And that's the actual path and file name (which obviously has no spaces in the path)?

I'd suggest just posting your actual script, running around chasing tails isn't much fun if you get my drift.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

And that's the actual path and file name (which obviously has no spaces in the path)?

I'd suggest just posting your actual script, running around chasing tails isn't much fun if you get my drift.

OK, same as my original post EXCEPT it has the FileExists in it:

All of the paths provided DO NOT have any spaces in the path.

Install.ini contains: AR603;\\<Server>\<Share>\Applications\Adobe_Reader\AdobeReader_603.EXE

Creds.ini contains: PASSWORD

No spaces are in the 'Install.ini' path to the executable.

CODE

$sProgram = "\\<server>\<share>\Automate_Installs\Install.ini" ;Path to the installation package on network

$sFile = "\\<server>\<share>\Automate_Installs\Creds.ini" ;Path to the Admin Password file

$sAccount = "Administrator"

$sMachine = @ComputerName

IF NOT FileExists( $sFile ) THEN ;Unable to locate the Admin Password File

MSGBOX(16,"Password Required","Unable to verify credentials! - Contact Help Desk")

Exit

ENDIF

IF NOT FileExists( $sProgram ) THEN

MSGBOX(16,"Install Program Required","Unable to determine the installation requested - Contact Help Desk")

Exit

ENDIF

$sPassword = FileReadLine( $sFile )

$sInstall = FileReadLine( $sProgram )

$array = StringSplit( $sInstall,";" ) ;1 = variable for package, 2 = path to EXE

IF FileExists( $array[2] ) THEN

RunAsSet($sAccount,$sMachine,$sPassword) ;Runs this portion as local admin

RUNWAIT( $array[2] )

RunAsSet() ;Returns everything back to normal

ELSE

MSGBOX(16,"ERROR","Unable to locate application")

ENDIF

Exit

If I remove the 'IF FileExists( $array[2] ) THEN' the application will not run.

If you try to fail and succeed which have you done?AutoIt Forum Search

Link to comment
Share on other sites

OK, looks like I came across an issue that no one out here can give a definite answer to, but I'm going to give this one more shot.

I was working on a different script and came across this issue again.

I have a dll which the script needs to copy to the workstation before the other tasks can be completed.

Here is how I wrote the script the first time:

CODE

$sMyDll = "\\<server>\<share>\SharedDlls\prnadmin.dll"

IF FileExists( $sMyDll ) THEN

FileCopy( $sMyDll,"C:\Temp\",1)

ELSE

MSGBOX( 16,"ERROR","Unable to locate " & $sMyDll )

EXIT

ENDIF

Everytime I ran this I got the ERROR message that I created, even though I verified the dll is there.

I also tried switching it around a bit and tried to use 'IF NOT FileExists( $sMyDll )' but got the same results.

Once I removed all of the 'FileExists', the script copied the dll to the correct location:

CODE

$sMyDll = "\\<server>\<share>\SharedDlls\prnadmin.dll"

FileCopy( $sMyDll,"C:\Temp\",1)

I was able to finish the rest of the script; registering the DLL and running the commands from that DLL.

Just curious as to why it wouldn't work until after I removed the 'FileExists' portion.

If you try to fail and succeed which have you done?AutoIt Forum Search

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...