Page 1 of 1 1
Topic Options
#155948 - 2006-01-25 07:39 PM How do I...
dataspike Offline
Getting the hang of it

Registered: 2005-03-09
Posts: 89
Loc: San Diego, CA
OK, here's what I'd like to be able to accomplish. Currently I have a function (below) that will allow me to update an application based on variables I call from the function. But I would like to be able to store the entries in a text file and have the function read the text file instead. That way the end user can update the file I don't have to create a new function call for each updated application. I have provided a sample of the text file format I would like to use. I hope I've explained it well enough.

Thanks!

Code:

Function AppUpdate($DisplayName,$originalfilename,$originalpath,$updatefilename,$updatepath)

$NetApp = $updatepath + "\" + $updatefilename
$LocalApp = $originalpath + "\" + $originalfilename

If Exist($LocalApp)
; $lblStatus.Text = "Checking for " + $DisplayName + "..."
$NetVer = GetFileVersion($updatefilename,"FileVersion")
; $lblStatus.Text = "Checking " + $DisplayName + "Version..."
$LocalVer = GetFileVersion($originalfilename,"FileVersion")
If $LocalVer <> $NetVer
; $lblStatus.Text = "Updating " + $DisplayName + ", please be patient..."
Copy $NetApp $LocalApp /h /r /c
; LogInfo("\\server1\itdept\mfg\install logs\" + $DisplayName + ".csv","@DATE,@TIME,@WKSTA,@USERID,$CurrentIP,Old Version: $LocalVer,New Version: $NetVer")
; $lblStatus.Text = "MFG Applications Updated..."
Sleep 0.5
EndIf
EndIf

EndFunction

AppUpdate("Test Application Update","TestApp.exe","%programfiles%\testapp","TestApp.exe","\\server1\updatedexes")



Here's the FloorUpdate.ini file
Quote:


Test Application Update,testapp.exe,%programfiles%\testapp,testapp.exe,\\server1\updatedexes
Notepad,notepad.exe,%windir%,notepad.exe,\\server2\testapp\new2





Edited by dataspike (2006-01-25 07:41 PM)

Top
#155949 - 2006-01-25 07:48 PM Re: How do I...
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Before you even start can I make a suggestion ? I would recommend you go with a true INI file format ... for two reasons ...

1) Its easier to parse using KiXtart.

2) Its easier to read and change for your end users.

If anyone wants to debate this, shoot now. Suggest a format like:

[Test Application]
DisplayName = Update
OriginalFilename = testapp.exe
OriginalPath = %programfiles%\testapp
UpdateFilename = testapp.exe
UpdatePath = \\server1\updatedexes

[Notepad]
DisplayName = Notepad
OriginalFilename = Notepad.exe
OriginalPath = %windir%
UpdateFilename = notepad.exe
UpdatePath = \\server2\testapp\new2

-Shawn

Top
#155950 - 2006-01-25 07:59 PM Re: How do I...
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Unless of course, this CSV file you propose is being generated from a spreadsheet or something.
Top
#155951 - 2006-01-25 08:00 PM Re: How do I...
dataspike Offline
Getting the hang of it

Registered: 2005-03-09
Posts: 89
Loc: San Diego, CA
To be honest I have ZERO problems going with that format, I was just doing a quick and dirty example. So that looks like a great start.

Now, the question is, how do I accomplish what I want to do? Since I will be setting sections in the INI file, how to I force the function to process through the entire file, and not have to specify in code each new application?

Top
#155952 - 2006-01-25 08:03 PM Re: How do I...
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
ja, thats the beauty of it, here is the code, assumption is you have a file called install.ini in the current dir formatted as above:

Code:

Break On

$PROFILE = ".\install.ini"

For Each $AppSection In Split(ReadProfileString($PROFILE, "", ""), CHR(10))

If $AppSection

?"App=" $AppSection

Endif

Next

Exit 0


Top
#155953 - 2006-01-25 08:05 PM Re: How do I...
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
and of course taking it to the next level ...

Code:

Break On

$PROFILE = ".\install.ini"

For Each $AppSection In Split(ReadProfileString($PROFILE, "", ""), CHR(10))

If $AppSection

$DisplayName = ReadProfileString($PROFILE, $AppSection, "DisplayName")
$OriginalFilename = ReadProfileString($PROFILE, $AppSection, "OriginalFileName")

?
?"DisplayName = " $DisplayName
?"OriginalFileName = " $OriginalFileName

Endif

Next

Exit 0


Top
#155954 - 2006-01-25 08:13 PM Re: How do I...
dataspike Offline
Getting the hang of it

Registered: 2005-03-09
Posts: 89
Loc: San Diego, CA
Quote:

and of course taking it to the next level ...

Code:

Break On

$PROFILE = ".\install.ini"

For Each $AppSection In Split(ReadProfileString($PROFILE, "", ""), CHR(10))

If $AppSection

$DisplayName = ReadProfileString($PROFILE, $AppSection, "DisplayName")
$OriginalFilename = ReadProfileString($PROFILE, $AppSection, "OriginalFileName")

?
?"DisplayName = " $DisplayName
?"OriginalFileName = " $OriginalFileName

Endif

Next

Exit 0






You

Thanks!

Top
#155955 - 2006-01-25 09:21 PM Re: How do I...
dataspike Offline
Getting the hang of it

Registered: 2005-03-09
Posts: 89
Loc: San Diego, CA
Finished Product...

Thanks Shawn.

Code:
Function Floor_App_Updates

$iniFile = @SCRIPTDIR + "\floorupdate.ini"

For Each $AppSection in Split(ReadProfileString($iniFile, "", ""), Chr(10))
If $AppSection
$DisplayName = ReadProfileString($iniFile, $AppSection, "DisplayName")
$OriginalFilename = ReadProfileString($iniFile, $AppSection, "OriginalFileName")
$OriginalPath = ReadProfileString($iniFile, $AppSection,"OriginalPath")
$UpdateFilename = ReadProfileString($iniFile, $AppSection, "UpdateFileName")
$UpdatePath = ReadProfileString($iniFile, $AppSection,"UpdatePath")
EndIf

$NetApp = $UpdatePath + "\" + $UpdateFilename
$LocalApp = $OriginalPath + "\" + $OriginalFilename

$lblStatus.Text = "Checking for " + $DisplayName + "..."
Sleep 0.25

If Exist($LocalApp)
$NetVer = GetFileVersion($UpdateFilename,"FileVersion")
$lblStatus.Text = "Checking " + $DisplayName + " version..."
$LocalVer = GetFileVersion($OriginalFilename,"FileVersion")
If $LocalVer <> $NetVer
$lblStatus.Text = "Updating " + $DisplayName + ", please be patient..."
Copy $NetApp $LocalApp /h /r /c
$lblStatus.Text = $DisplayName + " updated..."
Sleep 0.25
EndIf
EndIf
Next
Exit 0
EndFunction


Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 476 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.06 seconds in which 0.025 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org