cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
yBother
Level 2

Installshield: Copy file using powershell not working when running as Suite Action

I have a simple task that:

copy and replace an existing .json file on the target machine.

I am executing it as Event/Action in my Suite with elevated rights.

This is the  script:

 

 

try
{
$ProductName = "ravendb"
$Product = Get - WmiObject - Class Win32_Product | Where - Object { $_.Name - eq $ProductName}

if ($Product)
{
stop - service RavenDB
(Get - Service RavenDB).WaitForStatus('Stopped', '00:00:30')

$Folder = 'C:\RavenDB-4.2.x\Server'
Copy - Item - Path "settings.json" - Destination $Folder - force

start - service RavenDB
(Get - Service RavenDB).WaitForStatus('Running', '00:00:30')

exit(0)

}
else
{
exit(1)
}

}
catch
{
$StringValue = resolve - suitestring - StringId - Message
trace - suiteinfo - LogMessage $StringValue
exit(1)
}

 

 

 

Note that I tried to somehow print debug info to suiteinfo but I am not sure if that works.

Suite debug log says:

2-25-2023[01:26:47 PM]: Running event 'update-ravendb-settings'
2-25-2023[01:26:47 PM]: Engine: request for proxy handler, 0, 0
2-25-2023[01:26:48 PM]: (PowerShell Action): Attempting to load through CLR 4 APIs...
2-25-2023[01:26:48 PM]: (PowerShell Action): Getting meta host...
2-25-2023[01:26:48 PM]: (PowerShell Action): Enumerating available runtimes...
2-25-2023[01:26:48 PM]: (PowerShell Action): Highest available runtime: v4.0.30319
2-25-2023[01:26:48 PM]: (PowerShell Action): Trying to use highest runtime...
2-25-2023[01:26:48 PM]: (PowerShell Action): Using highest version runtime...
2-25-2023[01:26:57 PM]: Action returned value 0x00000000
2-25-2023[01:26:57 PM]: Action 'update-ravendb-settings' returned status 0x00000000

But the file has actually not been overwritten. Service is being stopped/restarted though.

Note that calling the script manually works just fine!

Why is it, that the copy/replace does not work when calling in suite?

Labels (1)
0 Kudos
(0) Replies