IT Management Suite

 View Only
  • 1.  Why doesn't my Task that is wrapped in a Policy work properly?

    Posted Jan 12, 2017 01:00 PM

    We have a problem where system administrators are logging into the wrong servers and then doing the wrong actions because of fat finger syndrome. So as to make sure that they are logged into the rigth machine, my manager has asked that users get a message that confirms what their computer is named and that this is then presented to the user on logon, with a question asking if they need to log off. Yes. I know.

    Anyway, I have a simple task called, "Confirm Computer Name" that contains a line such as:

    result = MsgBox("Logged On User: %LOGONUSER%. This computer is %COMPNAME%. Are you sure that you are here correctly?", vbYesNo, vbNo)

    And then it does other things, etc.

    This task works happily when run as a Task and the tokens are filled in as your would expect:

    Logged On User: Jim_Spriggs. This computer is DCS001. Are you sure that you are here correctly?

    However, when I run it as a task that is wrapped in a policy, I get the message box appearing with the tokens, such as:

    Logged On User: %LOGONUSER%. This computer is %COMPNAME%. Are you sure that you are here correctly?

    Why is this not working properly?

    Thanks in advance,

    QuietLeni



  • 2.  RE: Why doesn't my Task that is wrapped in a Policy work properly?

    Posted Jan 12, 2017 01:26 PM

    The reason is you are running it as policy and client initiates the task.  Since the client is initiating the task it is unaware of the tokens configured on the NS.  To get this to work in a policy you would have to do the following:

    result = MsgBox("Logged On User: %USER%. This computer is %COMPUTERNAME%. Are you sure that you are here correctly?", vbYesNo, vbNo)

    Hope that helps.

     



  • 3.  RE: Why doesn't my Task that is wrapped in a Policy work properly?
    Best Answer

    Posted Jan 13, 2017 07:35 AM

    No... That does not work - I tried it and the task still showed the environment variables. I resorted to using the Network object and here is the code:

    Set objNetwork = CreateObject("Wscript.Network")

    result = MsgBox("Logged On User: " & objNetwork.UserName & ". This computer is " & objNetwork.ComputerName & ".")

    And this works!

    Hope that it helps someone else.