none
Under what circumstance runas as administrator default to working directory as system32 and when it default to current directory RRS feed

  • Question

  • There is a batch file I found behaving different on two Windows 2012 R2 servers.

    On the first server, when runas administrator the batch file runs from its current directory (in this case c:\app) but on another server, when runas administrator the bath file, it runs from c:\windows\system32.

    I googled, there are solutions to make the batch file to always run from its current directory. However, that is not the point here, I want to know why the behaviour is not the same on 2 servers, both has the same patch level, same hardening settings, different being one is a physical server, the other is a virtual server.


    Valuable skills are not learned, learned skills aren't valuable.

    Tuesday, September 18, 2018 6:58 AM

All replies

  • The default behavior is when the command prompt is run as an admin, it open from c:\windows\system32

    Please check if the UAC is at the same level on both server


    Regards, Philippe

    Don't forget to mark as answer or vote as helpful to help identify good information. ( linkedin endorsement never hurt too :o) )

    Answer an interesting question ? Create a wiki article about it!

    Wednesday, September 19, 2018 1:16 AM
    Moderator
  • Hi,

    I agree with Philippe.

    There is a example for you.

    https://stackoverflow.com/questions/31622469/why-does-run-as-administrator-change-sometimes-batch-files-current-director

    Please note what Mofi said.

    Please Note: Since the web site is not hosted by Microsoft, the link may change without notice. Microsoft does not guarantee the accuracy of this information.
    Best Regards,

    Frank


    Please remember to mark the replies as an answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Wednesday, September 19, 2018 6:07 AM
    Moderator
  • Hi,

    Just check the situation about your issue.

    Best Regards,
    Frank

    Please remember to mark the replies as an answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Thursday, September 20, 2018 3:02 AM
    Moderator
  • Why marked it as answer when no answer was given.

    Already mentioned the hardening settings are the same, the UAC settings are therefore the same on both servers. Please note again that I am not looking for a solution but an explanation - why on one server runas administrator run from %windir%\system32 while on another server it runs from the current directory where the batch file is?

    Please do not mark as answer when no answer is given.


    Valuable skills are not learned, learned skills aren't valuable.

    Thursday, September 20, 2018 4:34 AM
  • If the UAC is at the same level, then please check if the path variable is the same on both server please.

    Regards, Philippe

    Don't forget to mark as answer or vote as helpful to help identify good information. ( linkedin endorsement never hurt too :o) )

    Answer an interesting question ? Create a wiki article about it!


    Thursday, September 20, 2018 4:35 PM
    Moderator
  • The path variable is the first thing I checked.

    On both servers, the directory where the batch file is located, is not in the path variable.

    The path variables are not exactly the same on both servers because the in-house application which add their paths into the path variables are of different names (in term of binaries, they are the same) hence different directory names on the 2 servers.


    Valuable skills are not learned, learned skills aren't valuable.

    Saturday, September 22, 2018 3:00 PM
  • If the variable are the same, please check the properties of cmd.exe, the start in is set where

    a example of where I mean


    Regards, Philippe

    Don't forget to mark as answer or vote as helpful to help identify good information. ( linkedin endorsement never hurt too :o) )

    Answer an interesting question ? Create a wiki article about it!

    Monday, September 24, 2018 12:49 PM
    Moderator
  • cmd.exe start in is %homedrive%%homepath%, same for both computers. Actually I had also checked this before posting.

    Valuable skills are not learned, learned skills aren't valuable.

    Saturday, October 6, 2018 2:51 AM