locked
How to know which account run the vbscript RRS feed

  • Question

  • I write a vbscript(e.g. abc.vbs ), and I want to know which account run this vbscript.

    I can open windows task manager to check processes's user name(system or useraccount ....), but I need to use running account information to judge. so I want to know, how to add some codes  and then this script can know which user account run it?

    Thanks in advance!

    Monday, January 20, 2014 2:36 AM

Answers

  • I'm not sure why you'd go to all that trouble with WMI unless you're trying to get this information from another process, outside the script. Inside the script, the WScript.Network object's "UserName" and "UserDomain" properties should always give you that information.
    • Marked as answer by Unknown32 Monday, January 20, 2014 9:17 AM
    Monday, January 20, 2014 4:23 AM

All replies

  • Just run it under the current account.  That is how we all for it unless you want to be an admin.  To be an admin takes a special step.

    ¯\_(ツ)_/¯

    Monday, January 20, 2014 3:04 AM
  • I want to judge if it is running by System,it doesn't need do anyhing, if it running is running by domain user account, it need to do somesthing.

    Monday, January 20, 2014 3:08 AM
  • I don't understand what you are asking.

    ¯\_(ツ)_/¯

    Monday, January 20, 2014 3:11 AM
  • Sorry for my poor English

    My question is "How Can I Determine Which Account a Script is Running Under?"

    And I found the answer from Scripting Guy! Blog

    http://blogs.technet.com/b/heyscriptingguy/archive/2006/02/16/how-can-i-determine-which-account-a-script-is-running-under.aspx

    Thank you for your replies!

    Monday, January 20, 2014 3:23 AM
  • I'm not sure why you'd go to all that trouble with WMI unless you're trying to get this information from another process, outside the script. Inside the script, the WScript.Network object's "UserName" and "UserDomain" properties should always give you that information.
    • Marked as answer by Unknown32 Monday, January 20, 2014 9:17 AM
    Monday, January 20, 2014 4:23 AM
  • Thanks for David, Your way is better
    Monday, January 20, 2014 9:17 AM