Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

I'm New Here I Need CMDebug Help

Jan
5
0
I've used various interactive debuggers over time and most have a way to move/set the next line to be executed. I didn't want to have to reset my batch file which is rather lengthy but instead just set the next line to be executed back a few lines. Is this an option in CMDebug? I've done more than enough searching and haven't been able to find anything that seems related to the info I seek. So if you can help me I'd appreciate it,
 
Ctrl-Shift-F11 may be your solution.

For example,
you've debugged down to line 25,
but you want to go back to line 20,
and start debugging from there.

From line 25,
arrow-up (or mouse click) to line 20,
then press Ctrl-Shift-F11.

Debugging now from line 20.

Joe
 
It took me a bit, but I did find the help for this under Debug;
Jump to This Line

If you click on a line in the debugger window and select "Jump to This Line",
the debugger will continue execution starting with the selected line.

You can can also change the line to be executed next when in debugging mode by moving the caret to the line and either right clicking & selecting "Jump to This Line" or by pressing Ctrl-Shift-F11.

Note that if you attempt to jump into or out of a DO loop or IFF block, bad things will happen!

Joe
Code:
     _x64: 1
   _admin: 1
_elevated: 1

TCC  29.00.17 x64   Windows 10 [Version 10.0.19044.2486]
 
Most of the prior IDEs I've used you had an arrow pointing to the next line to be executed and you could move that arrow to any line you wanted.

But now I have another problem.

Here's the code and the reason I wanted to go back to the line that's bolded was because I thought maybe I missed something because the execution didn't make sense.

) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
exit /B
:gotAdmin

I bolded the next active line and I'm expecting it to jump to :gotAdmin but that's not what happens. It simply moves to the italics line and continues on. There's no option on the else it should do an unconditional jump to :gotAdmin.
 
From the help file;
The IF ... ELSE ... syntax of CMD is also supported:

IF [/I] condition (command1) ELSE (command2)

The commands to be executed must be enclosed in parentheses (as in a command group).
If condition is TRUE,
command1 is executed,
if FALSE, command2 is executed.

Note: this syntax is much less powerful than the IFF command, which is recommended.

This works fine in a .btm, but in the past, I have had problems using the IF condition (command1) ELSE (command2) in the debugger, which is why I use the IFF syntax instead.
Code:
@setlocal
@echo off

set a=10

iff %a eq 10 then
  Gosub Command1
else
  Gosub Command2
endiff
quit

:Command1
echo Command 1
Return

:Command2
echo Command 2
Return

If you still want to use the IF condition (command1) ELSE (command2) in the debugger,
and want to use the "Jump to this line" in the debugger with that format,
that is something that @rconn would have to answer.

Joe
 
Most of the prior IDEs I've used you had an arrow pointing to the next line to be executed and you could move that arrow to any line you wanted.

But now I have another problem.

Here's the code and the reason I wanted to go back to the line that's bolded was because I thought maybe I missed something because the execution didn't make sense.

) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
exit /B
:gotAdmin

I bolded the next active line and I'm expecting it to jump to :gotAdmin but that's not what happens. It simply moves to the italics line and continues on. There's no option on the else it should do an unconditional jump to :gotAdmin.

An IF / ELSE statement is treated as a single line; you can't jump to an individual command inside the IF.
 
Ctrl-Shift-F11 may be your solution.

For example,
you've debugged down to line 25,
but you want to go back to line 20,
and start debugging from there.

From line 25,
arrow-up (or mouse click) to line 20,
then press Ctrl-Shift-F11.

Debugging now from line 20.

Joe
Is there a list of these CMDebug IDE commands somewhere. I can't seem to find the things I'm looking for like how to insert a line while actively debugging a bat.
 
You cannot insert a line while actively debugging using CMDebug.

The shortcut keys are listed beside each command on the menu drop-downs;

1675288887691.png


The help file also reviews what options are available on the drop-down menus;

1675288909447.png


Joe
 
Correct, no editing during execution.

Joe
 

Similar threads

Back
Top