1

我想知道...

我有一个程序,我想为此收费。

它在 Windows 上运行,主要用 VB 和批处理文件编写...

如何强制用户为其购买产品密钥,并激活它以使用付费版本?

提前致谢!

~ @Cascading 风格

4

1 回答 1

1

这只是一个小例子,向您展示您可以限制程序的执行次数,因此如果达到最大执行次数,程序将自行自动删除

@echo off
Setlocal enabledelayedexpansion
Title Count the number of times my BATCH file is run
Mode Con Cols=70 lines=7 & color 0E
Set /a MaxExecution=3
set /a count=1
set "FileCount=%tmp%\%~n0.dll"
If Not exist "%FileCount%" (
    echo !count! > "%FileCount%"
) else (
    For /F "delims= " %%a in ('Type "%FileCount%"') Do (
        set /a count=!count! + %%a
        echo !count! > "%FileCount%"
    )
)
echo.
echo             This Program is running for "!count!" time(s)
Call :SelfDelete
pause>nul & Exit /b
::**************************************************************
:SelfDelete
echo.
If !count! GTR !MaxExecution! (
    Color 0C
    echo The maximum execution of this "%~nx0" is set to "!MaxExecution!"
    echo and it is reached & Timeout /T 5 /Nobreak>nul & Del %~f0
    ) else (
    echo         The counting is "!count!" and the max is set to "!MaxExecution!"
)
Goto :EOF
::**************************************************************
于 2016-10-17T11:07:35.313 回答