- Inside MATLAB -> type !powershell in the command window. This will open power shell in interactive mode. From there you can execute your powershell commands.
- Use 'system' command in MATLAB and add the powershell command inside the 'system' function parenthesis.
How do you access Powershell in MATLAB interactively
29 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am trying to leverage the "-AsSecureString" feature in Powershell to hide some confidential text strings for future use. I am struggling at the first step. The command in cmd is
powershell "$a=Read-Host -Prompt 'enter your input' -AsSecureString"
which works well from cmd.
When I call the same command with the system function in MATLAB, I get an empty interface on which I can type anything but cannot exit. There is no prompt, and my input string is visible and not secure. Getting this to work would be ideal for my problem, and I can get this to work from cmd. unfortunately, calling it from MATLAB just does not work. Is there a work around for this?
0 Kommentare
Antworten (2)
Rahul
am 24 Jan. 2025
I understand that you wish to run powershell commands from MATLAB and are facing the issue of getting an exmpty interface. As suggested in the following MATLAB Answers, you consider following the given workarounds:
Here are examples:
% Workaround 1
!powershell
% Workaround 2
system(powershell "$a=Read-Host -Prompt 'enter your input' -AsSecureString")
Refer to the following MathWorks documentation to know more:
Thanks.
0 Kommentare
Walter Roberson
am 24 Jan. 2025
Powershell implies that you are using Windows. In that case you can use System.Diagnostics.Process to configure input and output to a Powershell process. See the outline at https://www.mathworks.com/matlabcentral/answers/2002092-system-diagnostics-process-doesn-t-execute-all-commands-in-external-file#answer_1280947
0 Kommentare
Siehe auch
Kategorien
Mehr zu Performance and Memory finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!