Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
lowriderdog37
- Posts: 4
- Joined: 16 Oct 2014 17:05
#1
Post
by lowriderdog37 » 16 Oct 2014 18:16
I did not write this script but had to modify some syntax to get it to work on my new win7 laptop. Now I am trying a few things to make it more user friendly. It sets configuration then opens dde, which is a protocol program then a spreadsheet. With the bottom written this way the spreadsheet opens and the script holds on until I close it which is EXACTLY what I want to happen. I tried to put a taskkill command in to close dde but it never worked and since then the script hangs after I close the spreadsheet.
Why it would do that? Any way to fix?
Code: Select all
@echo off
rem This batch file written to work with Windows 2000
rem Written by *****
rem Edited by ******* on Oct 2008
rem Edited by ***** on Oct 2014 to update for win7. BOOYA!
`
rem This batch file gets the user option for the type of view he wants,
rem then the connection path to use. It then copies the correct config
rem file for DDE to use and launches DDE. It then launches the appropriate
rem spreadsheet selected.
title=AFTAC M/C
rem Get user view choice.
:Main
cls
echo.
echo 1. Remote View
echo 2. Weeks 1 or 3
echo 3. Weeks 2 or 4
echo.
echo 0. Exit
echo.
choice /C:1230 /M "Select your option:"
if errorlevel 4 goto getout
if errorlevel 3 goto SetOpt3
if errorlevel 2 goto SetOpt2
if errorlevel 1 goto SetOpt1
:SetOpt1
set Option=RT
goto menu2
:SetOpt2
set Option=W1
goto menu2
:SetOpt3
set Option=W2
goto menu2
rem Get user choice for connection path.
:menu2
cls
echo.
echo Mount Newall
echo.
echo 1. Primary
echo 2. Secondary
echo.
echo Bull Pass
echo.
echo 3. Primary via Primary Repeater
echo 4. Primary via Secondary Repeater
echo 5. Secondary via Primary Repeater
echo 6. Secondary via Secondary Repeater
echo.
echo Other
echo.
echo 7. Direct Connect
echo 0. Return to Main
echo.
choice /c:12345670 /M "Please select the connection type:"
if errorlevel 8 goto Main
if errorlevel 7 goto Direct
if errorlevel 6 goto SecSec
if errorlevel 5 goto SecPri
if errorlevel 4 goto PriSec
if errorlevel 3 goto PriPri
if errorlevel 2 goto Sec
if errorlevel 1 goto Pri
rem Copy configuration for DDE to use.
rem Mt Newall primary connection
:Pri
copy c:\vanda\inifiles\MNPri.rst c:\dirctsft\bin\dsdde.rst > nul
goto loadprg
rem Mt Newall secondary connection
:Sec
copy c:\vanda\inifiles\MNSec.rst c:\dirctsft\bin\dsdde.rst > nul
goto loadprg
rem Bull Pass primary via Mt Newall primary connection
:PriPri
copy c:\vanda\inifiles\BPPriPri.rst c:\dirctsft\bin\dsdde.rst > nul
goto loadprg
rem Bull Pass Primary via Mt Newall secondary connection
:PriSec
copy c:\vanda\inifiles\BPPriSec.rst c:\dirctsft\bin\dsdde.rst > nul
goto loadprg
rem Bull
:SecPri
copy c:\vanda\inifiles\BPSecPri.rst c:\dirctsft\bin\dsdde.rst > nul
goto loadprg
rem Mt Newall secondary to Bull Pass secondary connection
:SecSec
copy c:\vanda\inifiles\BPSecSec.rst c:\dirctsft\bin\dsdde.rst > nul
goto loadprg
rem Direct connect through com1 port.
:Direct
copy c:\vanda\inifiles\Direct.rst c:\dirctsft\bin\dsdde.rst > nul
goto loadprg
rem Load DDE software
:loadprg
echo .
echo Please wait while DirectSoft and Excel load.
start c:\vanda\dsdde.lnk
rem 5 sec pause to open excel
TIMEOUT /T 5
rem for /L %T IN (1,1,50000) DO echo off
rem Load appropriate spreadsheet.
if %Option%==RT goto RMTVW
if %Option%==W1 goto week13
if %Option%==W2 goto week24
:RMTVW
c:\vanda\remote.xls
goto main
:week13
c:\vanda\Vannew_wk1_3.xls
goto main
:week24
c:\vanda\Vannew_wk2_4.xls
goto main
:getout
MOD EDIT: PLEASE USE CODE TAGS!!!!!!
-
Yury
- Posts: 115
- Joined: 28 Dec 2013 07:54
#2
Post
by Yury » 17 Oct 2014 02:31
lowriderdog37,
Code: Select all
:RMTVW
start "" "c:\vanda\remote.xls"
goto main
:week13
start "" "c:\vanda\Vannew_wk1_3.xls"
goto main
:week24
start "" "c:\vanda\Vannew_wk2_4.xls"
goto main
?
-
lowriderdog37
- Posts: 4
- Joined: 16 Oct 2014 17:05
#3
Post
by lowriderdog37 » 17 Oct 2014 14:07
I tried start but would like the script to wait until I closed the spreadsheet then close dde by itself.
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#4
Post
by foxidrive » 17 Oct 2014 17:33
It looks like you are starting a .lnk link which gives us no info on the process being started as it could be another batch file or any number of things.
It then branches depending the option that was given and loads a data file, and returns to the menu.
Do you see the menu in the cmd window when the spreadsheet is loaded?
If you press 0 to exit, what happens?
Are there any instructions after the :getout label?
-
lowriderdog37
- Posts: 4
- Joined: 16 Oct 2014 17:05
#5
Post
by lowriderdog37 » 17 Oct 2014 21:16
You are correct about the structure. dsdde.lnk and the spreadsheet open fine. The problem is that when I close the spreadsheet the script does not continue to 'goto main' it just sits there saying 'please wait....'.
When I am on the main menu I can press 0 and the script exits no problem. The code listed in the first post is the whole batch file and there is nothing after :getout.
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#6
Post
by foxidrive » 17 Oct 2014 21:47
Yury wrote:lowriderdog37,
Code: Select all
:RMTVW
start "" "c:\vanda\remote.xls"
goto main
:week13
start "" "c:\vanda\Vannew_wk1_3.xls"
goto main
:week24
start "" "c:\vanda\Vannew_wk2_4.xls"
goto main
?
Try using
start "" /w in Yury's code for all those lines.
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#7
Post
by foxidrive » 17 Oct 2014 21:49
lowriderdog37 wrote:The problem is that when I close the spreadsheet the script does not continue to 'goto main' it just sits there saying 'please wait....'.
I'm not sure what is saying 'please wait' as it isn't the batch file.
-
lowriderdog37
- Posts: 4
- Joined: 16 Oct 2014 17:05
#8
Post
by lowriderdog37 » 18 Oct 2014 13:34
It is just under :loadprg
/w worked. Turns out it was working the whole time but sometimes it takes up to a minute for the script to recognize the spreadsheet is closed and move on.
I also took out a ton of inefficiencies in the code structure. It is about 70% shorter now. I may play with it a little more and see if I can automate the loading/saving process we use the spreadsheet for.
Thanks for the help!