Product, version and build:
(*** Please do not write "latest" as a version, specify a version number ***)
32 or 64 bit version of product:64
Operating system:WIN7
32 or 64 bit OS:64 bit
I am using following command to copy one file from one location to another location using powershell compiled script I am getting following error. However when I run this directly in powershell script I am not getting error
.At line:3 char:17
robocopy $loglocal $logcentral $filename
I am getting error
Program 'Robocopy.exe' failed to run: The method or operation is not implemented at line 3 char 7.
However file is copying.
Please let me know what wrong I am doing here
robocopy is giving error with compiled script
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: robocopy is giving error with compiled script
When you package this into an exe, which engine are you using and which version of PowerShell are you targeting?
DevinL
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: robocopy is giving error with compiled script
HI
I am giving "Sapien PowerShell v2 Host(CommandLine)" as Engine and I am targeting PowerShell 2.0.
Please advise
Avian
I am giving "Sapien PowerShell v2 Host(CommandLine)" as Engine and I am targeting PowerShell 2.0.
Please advise
Avian
Re: robocopy is giving error with compiled script
In that case, can you provide the script you're working with? I'm still unable to reproduce this on my end and knowing more about the structure of your script could help point us in the right direction.
If need be, you can upload it to https://sapien.com/support/upload and the code will remain private.
If need be, you can upload it to https://sapien.com/support/upload and the code will remain private.
DevinL
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: robocopy is giving error with compiled script
Hi
Here is the script
$logLocal = "c:\users\$Env:USERNAME\AppData\Local\MyLogs\"
$centralizedLocation = "c:\appLogs\"
$copyLog=$logLocal +$Env:USERNAME+"_"+ "AdminActivity" +"_"+$logDate +".txt"
$filename = Split-Path $copyLog -leaf
robocopy $logLocal $centralizedLocation $filename
Let me know if you need more information.
Here is the script
$logLocal = "c:\users\$Env:USERNAME\AppData\Local\MyLogs\"
$centralizedLocation = "c:\appLogs\"
$copyLog=$logLocal +$Env:USERNAME+"_"+ "AdminActivity" +"_"+$logDate +".txt"
$filename = Split-Path $copyLog -leaf
robocopy $logLocal $centralizedLocation $filename
Let me know if you need more information.
Re: robocopy is giving error with compiled script
Can any one please help me out on above mentioned issue?
Re: robocopy is giving error with compiled script
Sorry, I'm looking into this today and I will get back to you as soon as possible.
DevinL
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: robocopy is giving error with compiled script
Unfortunately, I'm unable to reproduce this on my end at the moment, here is what I did in my attempt to reproduce it:
First I copied your script over and cleaned it up a bit to work in my current environment and this was the end result (I've also attached the script and psbuild to the bottom of this post just in case):
I added comments to the major changes I made so you can see what I did much easier.
I packaged this script into an exe using the SAPIEN PowerShell V2 Host (Command Line) engine, and targetted the 64-bit platform, all other packager settings remained the defaults.
Here is a screenshot of the results when I ran the executable on my machine: Were there any steps that I may have taken differently than how it is run in your environment? If so, please let me know and I'll do my best to reproduce. In the meantime, I'll see if I can't find a workaround to get your script working.
First I copied your script over and cleaned it up a bit to work in my current environment and this was the end result (I've also attached the script and psbuild to the bottom of this post just in case):
- # Original script lacked the source for $LogDate, so I use this in its place
- $LogDate = Get-Date -Format "M.d.yyy_HH.mm.ss"
- # Replaced C:\Users\$env:USERNAME with $env:USERPROFILE
- $LogLocal = "$env:USERPROFILE\AppData\Local\MyLogs\"
- $CentralizedLocation = "C:\AppLogs\"
- $CopyLog = $LogLocal + $Env:USERNAME + "_AdminActivity_" + $LogDate + ".txt"
- $Filename = Split-Path $CopyLog -leaf
- # Verified the file existed, if not, create it so robocopy won't throw an error
- if (-not (Test-Path $CopyLog)) {
- New-Item -Path $CopyLog -ItemType File
- }
- robocopy $LogLocal $CentralizedLocation $Filename
I packaged this script into an exe using the SAPIEN PowerShell V2 Host (Command Line) engine, and targetted the 64-bit platform, all other packager settings remained the defaults.
Here is a screenshot of the results when I ran the executable on my machine: Were there any steps that I may have taken differently than how it is run in your environment? If so, please let me know and I'll do my best to reproduce. In the meantime, I'll see if I can't find a workaround to get your script working.
- Attachments
-
- Robocopy_Test.ps1.zip
- (1.35 KiB) Downloaded 149 times
DevinL
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: robocopy is giving error with compiled script
Hello Devinl
I downloaded your code and compiled the exe but getting same error. Please see the attached error.
Is it because I am using trial version of Primal Script 2017?
My Current environment is Windows 7 64 bit and OS is also 64 bit.
Please advise.
I downloaded your code and compiled the exe but getting same error. Please see the attached error.
Is it because I am using trial version of Primal Script 2017?
My Current environment is Windows 7 64 bit and OS is also 64 bit.
Please advise.
- Attachments
-
- error1.jpg (264.07 KiB) Viewed 15212 times
Re: robocopy is giving error with compiled script
The fact that you're using a trial version shouldn't have any effect, I just fired up a Windows 7 64-bit machine with a trial installation of PrimalScript and was able to build and execute the script as expected:
It seems to be executing correctly, but then attempting to execute itself again only to error. You did point out that the file is copying, so I'm thinking this is something to do with the specific environment on that machine. I'll speak with the team and see what ideas they may have and get back to you.DevinL
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.