Jump to content

Can't compile script.


Guest pkelly
 Share

Recommended Posts

Guest pkelly

Global $ocx[5]
Global $bak[5]
Global $i=0
Global $sysdir=@windowsdir & "\system32\"
Global $install=1

$ocx[0]="CSCmd32.ocx"
$ocx[1]="CSText32.ocx"
$ocx[2]="cscal32.ocx"
$ocx[3]="CSVLST32.ocx"
$ocx[4]="csspin32.ocx"

$bak[0]="CSCmd32.bak"
$bak[1]="CSText32.bak"
$bak[2]="cscal32.bak"
$bak[3]="CSVLST32.bak"
$bak[4]="csspin32.bak"

If $install=1 then
While $i<5 
   If FileExists($sysdir & $ocx[$i])=1 then
     FileCopy($sysdir & $ocx[$i], $sysdir & $bak[$i]);   make backups
   EndIf

   FileInstall("C:\1\" & $ocx[$i], $sysdir & $ocx[$i], 1);  install file w/o overwriting
   
   RunWait(@ComSpec & " /c " & 'regsvr32 /s $sysdir & $ocx[$i]', "", @SW_HIDE); register the files
   $i=$i + 1
WEnd
endif
   
If @error="0" then
msgbox(4096, "System", "The OCX files have been successfully updated.")
else 
msgbox(4096, "System", "There was an error during installation.")
endif

Hiya, I'm new to the forum and i've got quite a question. I'm semi-new to scripting and I'm somewhat unfamiliar with AutoIT. For some reason I'm not able to compile this script...BUT it works fine in au3 format. I have attempted to compile it from the context menu and from the script converter program and I crash using both of these. HELP!

Link to comment
Share on other sites

Problem is with FileInstall():

The source path of the file to compile. This must be a literal string; it cannot be a variable.

You have to hard code it for the compile

The FileInstall function is designed to include files into a compiled AutoIt script. These included files can then be "extracted" during execution of the compiled script. Keep in mind that files such as images can greatly increase the size of a compiled script.
The source file must be a string and not a variable so that the compiler can extract the filename to include. The source cannot contain wildcards.

When this function is used from a non-compiled script, a copy operation is performed instead (to allow for easy testing pre-compilation).
Files maintain their original creation/modification timestamps when installed.
Edited by steveR
AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.
Link to comment
Share on other sites

Guest pkelly

Hmm... i see that now. Since I have 5 different files that I'm compiling into the exe, do i have to have 5 different statements? Or is there another way to throw these into a loop?

Link to comment
Share on other sites

Or is there another way to throw these into a loop?

None that I can think of to get past the no-variable rule. I've never used FileInstall so maybe someone else knows a trick or something... Edited by steveR
AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.
Link to comment
Share on other sites

Guest pkelly

None that I can think of to get past the no-variable rule. Maybe someone else knows a trick or something...

<{POST_SNAPBACK}>

I'm thinking that i can install the 5 files into the directory as a different name and then FileCopy() them after the backup process.... Thank you for the reply steveR
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...