i have following batch file
connect.bat
@Echo Off
SetLocal
(Set RAS_con=connection)
(Set RAS_usr=user)
(Set RAS_pwd=password)
:Online_check
Rasdial | Find /V /N "" | FindStr /R "^\[3\]" && (
Echo %DATE% %TIME% -- Still online. Delaying 60s...
Ping -n 61 localhost > NUL
Goto Online_check)
Echo %DATE% %TIME% -- Offline. Reconnecting to "%RAS_con%"...
Rasdial "%RAS_con%" %RAS_usr% %RAS_pwd% && Goto Online_check
Echo %DATE% %TIME% -- Error connecting to "%RAS_con%".
EndLocal
and i want to link it to a .ini or .txt file which contain connection,user and
password
for e.g. a info.ini can be like this
info.ini
(Set RAS_con=connection)
(Set RAS_usr=user)
(Set RAS_pwd=password)
how to link batch file with .ini or .txt
Moderator: DosItHelp
-
- Expert
- Posts: 391
- Joined: 19 Mar 2009 08:47
- Location: Iowa
Easiest thing to do is set the INI file as just another CMD file and call it:
info.cmd
connect.cmd
If you insist on using an extension of INI then you can do this:
info.ini
connect.cmd
info.cmd
Code: Select all
Set RAS_con=connection
Set RAS_usr=user
Set RAS_pwd=password
connect.cmd
Code: Select all
@echo off
call info.cmd
:online_check
. . . .
If you insist on using an extension of INI then you can do this:
info.ini
Code: Select all
Set RAS_con=connection
Set RAS_usr=user
Set RAS_pwd=password
connect.cmd
Code: Select all
@echo off
for /f "delims=" %%a in (info.ini) do %%a
:online_check
. . . .
avery_larry wrote:Easiest thing to do is set the INI file as just another CMD file and call it:
info.cmdCode: Select all
Set RAS_con=connection
Set RAS_usr=user
Set RAS_pwd=password
connect.cmdCode: Select all
@echo off
call info.cmd
:online_check
. . . .
If you insist on using an extension of INI then you can do this:
info.iniCode: Select all
Set RAS_con=connection
Set RAS_usr=user
Set RAS_pwd=password
connect.cmdCode: Select all
@echo off
for /f "delims=" %%a in (info.ini) do %%a
:online_check
. . . .
thank u sooooooooo.... much
in first step i did following things:
connect.cmd
Code: Select all
@Echo Off
call info.cmd
:Online_check
Rasdial | Find /V /N "" | FindStr /R "^\[3\]" && (
Echo %DATE% %TIME% -- Still online. Delaying 60s...
Ping -n 61 localhost > NUL
Goto Online_check)
Echo %DATE% %TIME% -- Offline. Reconnecting to "%RAS_con%"...
Rasdial "%RAS_con%" %RAS_usr% %RAS_pwd% && Goto Online_check
Echo %DATE% %TIME% -- Error connecting to "%RAS_con%".
EndLocal
info.cmd
Code: Select all
Set RAS_con=connection
Set RAS_usr=user
Set RAS_pwd=password
and it works perfectly
IInd step:
connect.cmd
Code: Select all
@Echo Off
for /f "delims=" %%a in (info.ini) do %%a
:Online_check
Rasdial | Find /V /N "" | FindStr /R "^\[3\]" && (
Echo %DATE% %TIME% -- Still online. Delaying 60s...
Ping -n 61 localhost > NUL
Goto Online_check)
Echo %DATE% %TIME% -- Offline. Reconnecting to "%RAS_con%"...
Rasdial "%RAS_con%" %RAS_usr% %RAS_pwd% && Goto Online_check
Echo %DATE% %TIME% -- Error connecting to "%RAS_con%".
EndLocal
info.ini
Code: Select all
Set RAS_con=connection
Set RAS_usr=user
Set RAS_pwd=password
but in second step a error message appears like below:
-
- Expert
- Posts: 391
- Joined: 19 Mar 2009 08:47
- Location: Iowa