WeTi
asked on
Powershell accessing to the desktop
Dear expert
Powershell: $env: USERPROFILE\desktop\folder \
now when I run it, it tells me a error that permission denied... ok weird... I don't use right to access my desktop? Now when I try and full path, it works well...
What is the problem?
Regards
WeTi
Powershell: $env: USERPROFILE\desktop\folder
now when I run it, it tells me a error that permission denied... ok weird... I don't use right to access my desktop? Now when I try and full path, it works well...
What is the problem?
Regards
WeTi
ASKER
Hi oBdA
Its a decryption script by calling openssl. the error I get is:
openssl.exe : Can't open C:\Users\weti\desktop\secr et for reading, Permission denied
Its a decryption script by calling openssl. the error I get is:
openssl.exe : Can't open C:\Users\weti\desktop\secr
Function Decry {
$Input = "$env:USERPROFILE\desktop\secret"
$Output = "$env:USERPROFILE\desktop\secret"
$UniqueKey = '(stdin)= aef44983e90b10***4af1742a15***8942'
$KeyFile = "$env:USERPROFILE\desktop\secret"
$RandomkeyFileName = Get-Random
$KeyFileExtractPath = "$Env:APPDATA\Microsoft"
openssl.exe enc -aes-256-cbc -salt -d -in $KeyFile -out $KeyFileExtractPath\"$RandomkeyFileName.key" -k $UniqueKey
$ReadKey = Get-Content -Path $KeyFileExtractPath\"$RandomkeyFileName.key"
$AllFiles = Get-ChildItem -Path $Input | ?{$_.Extension -eq $null -or $_.Extension -eq ""}
ForEach ($EachFile in $AllFiles){
$fullPath = $EachFile.FullName
$FileName = $EachFile.Name
ForEach ($FileNameS in $ReadKey){
$FileH,$FileN = $FileNameS.split(",",2)
Write-Host "$FileH" -ForegroundColor Yellow
Write-Host "$FileName" -ForegroundColor Green
if($FileH -eq $FileName){
Write-Host "Decrypted File : $FileN" -ForegroundColor Black -BackgroundColor White
openssl.exe enc -aes-256-cbc -salt -d -in $fullPath -out $Output\$FileN -k $UniqueKey
}
}
}
Remove-Item $KeyFileExtractPath\"$RandomkeyFileName.key" -Force
}
Decry
ASKER
Thing is if I directly type:
$Input = 'C:\Users\weti\desktop\sec ret' This works... now because it will be a network shared script so env: must work tho...
$Input = 'C:\Users\weti\desktop\sec
ASKER
now I lied... direct input didn't work as well, same problem
Replace $Input with $SourceFolder or whatever. $Input is a default variable.
$input gotchas
https://dmitrysotnikov.wordpress.com/2008/11/26/input-gotchas/
$input gotchas
https://dmitrysotnikov.wordpress.com/2008/11/26/input-gotchas/
ASKER
Did, didn't help, same problem. Now I really dont know what the hell is going on... It worked before with direct path...
Use
NVM
"$($env:USERPROFILE)\desktop\folder\"
NVM
now I lied... direct input didn't work as well, same problem
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
After a restart, things started working well again. With my old option: $env:USERPROFILE
You need to be more specific about what it is you're trying to do and the exact error message you're getting.