none
PowerShell - Expirate the Program RRS feed

  • Question

  • Hello

    I developed an application in PowerShell with windows Forms.
    I would like to make a condition for the executable to expire on the date I determine.
    I made this condition in another application that I developed in VB.NET, but I didn't find how to do it in power shell

    in VB it looked like this:

    Dim dt1 = DateTime.Now
            Dim dt2 = DateTime.Parse("30/09/2019")

            If dt1 >= dt2 Then
                MsgBox("Expired Date - Please Contact Administrator")
                Application.Exit()
           
            End If

    Does anyone know how I do this in powerShell? no need to have msgbox, just want the program not to run, not open, do nothing when it arrives on the set date

    Thank you very much in advance.

    Tuesday, October 8, 2019 9:59 PM

All replies

  • help Get-Date -online

    or

     [datetime]::ParseExact('30/09/2019','dd/MM/yyyy',$null)

    For a message box use the Microsoft.VisualBasic namespace to access the MsgBox.

    [Microsoft.VisualBasic.Interaction]::MsgBox( " my message" )


    \_(ツ)_/



    • Edited by jrv Tuesday, October 8, 2019 10:20 PM
    Tuesday, October 8, 2019 10:11 PM