none
Using Powershell as COMSPEC RRS feed

  • Question

  • Hi Folks,

    I am trying to setup COMSPEC as powershell as default interpreter. This helps me to handle the situation if the current directory is an UNC for applications being launched using system(..).  We also have thirdparty tools for to support unix utilities under Windows. One of them is ls.exe.  In my testing, I found system("ls -al") was being picked from Powershell instead of the thirdparty directory which is already in PATH. Is there any way I can avoid using powershell alias through an environment variable? Or use a custom alias redirecting to thirdparty directory by an environment variable? Or is there any way to stop using alias from powershell and just use as interpreter by environment variable?

    -Karthik


    Karthik

    Friday, May 16, 2014 7:05 PM

Answers

  • My recommendation is not to change COMSPEC as this may break other tools that assume COMSPEC is pointing to cmd.exe. As jrv noted, you need to explain what you want to do, not how you think it needs to be done.


    -- Bill Stewart [Bill_Stewart]

    Monday, June 16, 2014 9:53 PM
    Moderator

All replies

  • What alias.  There is no commandline alias for PowerShell.

    You cannot change COMSPEC as it only applies to CMD.EXE.

    It would be better if you just said what issue you were having without proposing a technical solution.


    ¯\_(ツ)_/¯

    Friday, May 16, 2014 7:57 PM
  • Is there a strict documentation saying COMSPEC apply just to cmd.exe? As I understand this can be applied to any interpreter you wish to use apart from cmd.exe.

    -Karthik


    Karthik

    Friday, May 16, 2014 8:48 PM
  • Okay here is the question - 

    I want to launch a process whose current directory is UNC through system(..) call. I don't want to map the path to a temporary drive through pushd technique and also don't want users to map an explicity drive to UNC. Is there a solution to do it through cmd.exe? I am trying to use Powershell since it works well with UNC.

    -Karthik


    Karthik

    Friday, May 16, 2014 8:51 PM
  • I want to launch a process whose current directory is UNC through system(..) call.

    Why?


    -- Bill Stewart [Bill_Stewart]

    Friday, May 16, 2014 9:01 PM
    Moderator
  • Okay here is the question - 

    I want to launch a process whose current directory is UNC through system(..) call. I don't want to map the path to a temporary drive through pushd technique and also don't want users to map an explicity drive to UNC. Is there a solution to do it through cmd.exe? I am trying to use Powershell since it works well with UNC.

    -Karthik


    Karthik

    A UNC cannot be a current directory.  You need a provide the have a current directory. 

    You can have a UNC as a path or in the path or use it as a path but it is not  drive.

    You need to explain what you are trying to do instead of telling us how to do it. Right now your explanation just doesn't make much sense.


    ¯\_(ツ)_/¯

    Friday, May 16, 2014 9:09 PM
  • Okay here is the question - 

    I want to launch a process whose current directory is UNC through system(..) call. I don't want to map the path to a temporary drive through pushd technique and also don't want users to map an explicity drive to UNC. Is there a solution to do it through cmd.exe? I am trying to use Powershell since it works well with UNC.

    -Karthik


    Karthik

    CMD use UNC paths just fine.  What are you using in PowerShell that you think you can't do in CMD.


    ¯\_(ツ)_/¯

    Friday, May 16, 2014 9:11 PM
  • Do you still need help with this question?

    -- Bill Stewart [Bill_Stewart]

    Friday, June 13, 2014 9:43 PM
    Moderator
  • My recommendation is not to change COMSPEC as this may break other tools that assume COMSPEC is pointing to cmd.exe. As jrv noted, you need to explain what you want to do, not how you think it needs to be done.


    -- Bill Stewart [Bill_Stewart]

    Monday, June 16, 2014 9:53 PM
    Moderator