/build/static/layout/Breadcrumb_cap_w.png

AlwaysInstallElevated and Custom actions

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

Answers (3)

Posted by: ZhuBaJie 19 years ago
Orange Belt
0
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.

=[AppendToServicesTable.vbs]==================================
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
targetFile.WriteLine(input)
Loop
targetFile.Close
ObjTextFile.close
======================================================

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

=[RestoreServicesTable.vbs]===================================
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
destfile.WriteLine(Input)
else
Input2 = AddOnFile.ReadLine
end if
Input = ServicesFile.ReadLine
loop
'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.
DestFile.WriteLine(Input)
end if
Loop
DestFile.Close
servicesFile.Close
AddOnFile.Close

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.
ServicesFile.delete

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

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

=[SapAdditionsToServicesTable]=================================
sapdp00 3200/tcp
sapdp01 3201/tcp
sapdp02 3202/tcp
....snap, ....snap....
======================================================

I hope this helps.
Marcel
Posted by: DuncanPaul 19 years ago
Orange Belt
0
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
Posted by: akhlaque 19 years ago
Orange Senior Belt
0
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.
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ