is server.Disconnect async ?

StarWind VTL, VTL Free, VTL Appliance
Post Reply
mete
Posts: 18
Joined: Thu Oct 23, 2025 4:23 pm

Fri Oct 24, 2025 1:13 pm

I am trying to delete the folder (Remove-Item) under headers after removing a device (with Remove-Device). After Remove-Device or after server.Disconnect or checking server.Connected property, I cannot remove the files because it says they are used by another process. If I wait a second (sleep 1), I can delete it. I guess server is keeping the file open (?), is there a way to do this ?
yaroslav (staff)
Staff
Posts: 4310
Joined: Mon Nov 18, 2019 11:11 am

Fri Oct 24, 2025 1:29 pm

You need to remove the devices by running the Remove script. Then, once the device is removed from StarWind.cfg, you can delete it from headers/underlying storage.
mete
Posts: 18
Joined: Thu Oct 23, 2025 4:23 pm

Fri Oct 24, 2025 2:50 pm

By Remove script, if you mean Remove-Device, the below does not work:
Remove-Device -server $server -deviceId $device.DeviceId
Remove-Item -Path "$STARWINDS_HEADERS_FOLDER\$libraryName" -Force -Recurse
results
Remove-Item : Cannot remove item C:\Program Files\StarWind Software\StarWind\headers\myvtl\myvtl.swdsk: The process
cannot access the file 'myvtl.swdsk' because it is being used by another process.
If I put a sleep 1 before Remove-Item, it works. Maybe it is system related.
yaroslav (staff)
Staff
Posts: 4310
Joined: Mon Nov 18, 2019 11:11 am

Fri Oct 24, 2025 3:01 pm

Thanks for your hint.
Yes, it could be something in the service not letting the header go in time.
Post Reply