hi all,

have an issue with deployment, unfortunately have to install in the user context, and our custom deployment mechanism sets the AlwaysInstallElevated keys before calling the msi.
this works ok, so for instance if I wanted to overwrite a system file, it works fine, my issue is this, I need to copy a file in script, so have made the script that edits and builds the services file, but then I need to overwrite it in drivers\etc. can't seem to do it, and I'm wondering if it's because of where in the procedure the CA is located.

I've tried both in execute immediate and deferred (the latter being where I'd expect it to work correctly), but just can't seem to get the action to work. It definitely falls over on permissions, yet if I just included the file it can copy it to the machine fine, so the permissions are definitely getting elevated for that action.

any help much appreciated.
0 Comments   [ + ] Show Comments


Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.


Hi Paul,

I did this long ago for the SAP client and it worked like a charm. I even put it in Execute Immediate if I recall correctly. One of my first custom actions.

Here are the scripts I used.

Option Explicit

Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim targetfile
Dim input
Dim objFSO
Dim objTextFile
Dim target
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set targetfile = objFSO.GetFile("C:\WINDOWS\system32\drivers\etc\services")
Set input = objFSO.GetFile("C:\WINDOWS\system32\drivers\etc\SapAdditionsToServicesTable")

' Append the contents of SapAdditionsToServicesTable to the Services file.
' There needs to be an empty line at the end of the Services file or at the
' SapAdditionsToServicesTable file.
Set objTextFile = objFSO.OpenTextFile (input, ForReading)
Set target = CreateObject("Scripting.FileSystemObject")
Set targetFile = target.OpenTextFile (targetfile, ForAppending, True)
Do Until objTextFile.AtEndOfStream
input = objTextFile.Readline

When you deinstall the application you want to restore the Services file to it's old state,
without removing lines that here added later.

Option Explicit
Dim ServicesTabel, ServicesFile
Dim AddOn, AddOnFile
Dim Dest, DestFile
Dim Input, Input2
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")

Set ServicesTabel = CreateObject("Scripting.FileSystemObject")
Set ServicesFile = ServicesTabel.OpenTextFile("C:\WINDOWS\system32\drivers\etc\services", 1)

Set AddOn = CreateObject("Scripting.FileSystemObject")
Set AddOnFile = AddOn.OpenTextFile("C:\WINDOWS\system32\drivers\etc\SapAdditionsToServicesTable", 1)

'The result goes to the new Services file.
Const ForAppending = 8
Set Dest = CreateObject("Scripting.FileSystemObject")
Set DestFile = Dest.OpenTextFile("C:\WINDOWS\system32\drivers\etc\result.txt",ForAppending, True)

Input2 = AddOnFile.ReadLine
Do Until ServicesFile.AtEndOfStream
Input = ServicesFile.ReadLine
'Read the Services file until we find a match.
Do Until AddOnFile.AtEndOfStream
if not(Input=Input2) then
Input2 = AddOnFile.ReadLine
end if
Input = ServicesFile.ReadLine
'When we are at the end of the AddOn list, we know the rest is added later,
'so we write everything to Dest.
if not(Input=Input2) then
'Write the line.
end if

Set ServicesFile = objFSO.GetFile("C:\WINDOWS\system32\drivers\etc\services")
Set DestFile = objFSO.GetFile("C:\WINDOWS\system32\drivers\etc\result.txt")
Set AddOnFile = objFSO.GetFile("C:\WINDOWS\system32\drivers\etc\SapAdditionsToServicesTable")

'Delete the old Servicestabel.

'Rename BackupVanServices to Services.
DestFile.move ("C:\WINDOWS\system32\drivers\etc\services")

'Remove the AddOn file, it's no longer needed.

sapdp00 3200/tcp
sapdp01 3201/tcp
sapdp02 3202/tcp
....snap, ....snap....

I hope this helps.
Answered 09/26/2005 by: ZhuBaJie
Orange Belt

Please log in to comment
thanks for the help, it does look very similar to my one, unfortunately the script isn't the issue, my script works fine, the issue is that it doesn't have permissions to execute when run as a user using alwaysinstallelevated
Answered 09/26/2005 by: DuncanPaul
Orange Belt

Please log in to comment
Hi duncan:

Have to tried setting the value of AlwaysInstalledElevated to 1.
Can u show my the scirpt bcoz the sometime ur script works fine.
But when u run it in wise it wont wok.
Answered 09/28/2005 by: akhlaque
Orange Senior Belt

Please log in to comment
Answer this question or Comment on this question for clarity