Do not ask why, I am also very worried. But so wants the customer.

You must copy the file X:\Folder1\Folder2\...\Project.exe to the folder \\Server\Folder3\Folder4\...\ and rename it as Project_1.5.6047.21408.exe , where 1.5.6047.21408 the file version number .

  • Project.exe a .net application? - kmv
  • Yes, the application. It has a file version. (Properties -> Details -> File Version (Product Version)) - Dmitry Chistik

1 answer 1

In Powershell, any .NET Framework functions are available, so the file version can be obtained via the FileVersionInfo.GetVersionInfo method.

 # файл для копирования и переименования $input = 'X:\Folder1\Folder2\...\Project.exe' # каталог назначения $output = '\\Server\Folder3\Folder4\...\' $path = [System.IO.Path] $version = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($input).ProductVersion.ToString() $newFile = $path::GetFileNameWithoutExtension($input) + "_$version" + $path::GetExtension($input) $output = $path::Combine($output, $newFile) Copy-Item "$input" -Destination "$output" 

ProductVersion can try FileVersion .

  • In essence, I only needed [System.Diagnostics.FileVersionInfo]::GetVersionInfo($input).ProductVersion.ToString() thanks! - Dmitry Chistik