Batch if first time starting

时间:2016-02-12 20:23:23

标签: batch-file

I'm in progress of making little program...So, if you are new user, program must open new programs that asks for priviliges..

So i made something like this:

 protected void TransferFileBtn_Click(object sender, EventArgs e)
    {
        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModal", "$('#myModal').modal();", true);

    }

And "firsttime" its:

:reg
if exist reg.txt goto home
if not exist reg.txt goto firsttime

But program sents me to firsttime every time! Anybody that can help me? Thanks! <3

2 个答案:

答案 0 :(得分:0)

将该行重写为:

:reg
if exist "%USERPROFILE%\reg.txt" (goto :home) Else (goto :firsttime)
Goto :EOF

这将在用户个人资料文件夹中查找该文件,但您可以将其更改为任何其他文件夹。

您需要指定文件的完整路径,否则可能会显示错误的位置。您可以使用C:\或\\ share \ folder路径,但需要提供它。

答案 1 :(得分:0)

如果没有比你发布的更多的代码,就无法分辨。

可以是你的代码“落到”:firsttime - 没有它,我们无法分辨。

我会将其编码为

:reg
set "regfile=c:\reg.txt"
if exist "%regfile%" goto home
:: First time through
cls
echo Blah blah blah
...
echo something>"%regfile%"
:home

当然,精确的绝对路径名和文件名完全取决于您。

您可能(未指定)想要在路径或文件名中包含用户名,或者您可能希望将有关多个用户的所有数据存储在单个文件中 - 未指定,并且需要完全不同的方法...