Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dw should get the AppData/LocalAppData folder locations on Windows without crashing due to a PowerShell $Profile script #20

Open
BrianL-STCU opened this issue Dec 10, 2020 · 0 comments

Comments

@BrianL-STCU
Copy link

Describe the bug
To get the ApplicationData and LocalApplicationData user folders on Windows, a complex PowerShell command line is used, but can be broken if the user's PowerShell profile script has unexpected output.

To Reproduce
Steps to reproduce the behavior:

  1. Add the following to your PowerShell $Profile script:
Write-Host "?`n?"
  1. Run dw "output application/json --- true"
  2. Get a stack trace of java.nio.file.InvalidPathException: Illegal char <?> at index 0

Expected behavior
The AppData and LocalAppData folders are available as simple environment variables (APPDATA and LOCALAPPDATA, respectively), or you can use the simple PowerShell expressions [Environment]::GetFolderPath('ApplicationData') and [Environment]::GetFolderPath('LocalApplicationData') without compiling C# code via Add-Type to get at the low-level Windows API. But if you use PowerShell, be sure to include the -NoProfile and -NonInteractive parameters for the powershell.exe, otherwise the user profile script is implicitly executed before your -Command parameter, which can have unexpected results, and can even block execution.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Windows 10 version 20H2
  • Windows PowerShell 5.1.19041.546
  • DataWeave Command Line : V1.0.9
  • DataWeave Runtime: V2.3.2-SNAPSHOT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant