I want my program to change current directory exactly like Set-Location
command. So my program executes, then I see a different directory in my command prompt.
This DOES NOT WORK:
Directory.SetCurrentDirectory(Scripts);
Environment.CurrentDirectory = Scripts;
This changes current directory for the executing process, not the executing shell directory.
What I see:
PS C:\Users\Test>test.exe
PS C:\Users\Test>
What I want is:
PS C:\Users\Test>test.exe
PS C:\Test>
Yep, I execute this from PowerShell, but I do not want a PowerShell script, I need my C# application to change the shell path for me, and then continue the same shell. Of course it should also work in cmd.exe.
I'd like to avoid creating a separate shell, instead I want my program to act as a shell command. If you curious it's a configuration manager, which should configure script directory according to a template name given as command argument, it should change the path to configured scripts directory.