Visual Studio 2017 debugging vbscript
Asked Answered
F

3

6

I'd like to debug a vbscript with Visual Studio 2017 Community Edition and followed the steps mentioned here for VS2015:

Video

I entered

cscript.exe /x foo.vbs

in the commandline, but no debugger starts. Is there a problem with the 2017th version of VS or are there some steps (e.g. configuration steps in VS) which are not shown in the video?

Edit: I tried cscript.exe //X foo.vbs , cscript.exe foo.vbs //X , cscript.exe //X //D foo.vbs and cscript.exe foo.vbs //X //D too

Thanks steff

Frontal answered 28/5, 2017 at 10:26 Comment(2)
Please list the actual instructions and steps you followed instead of linking to a video. The video doesn't have textual descriptions and my computer doesn't have speakers right now.Pshaw
I have edited the questionFrontal
P
5

Neither of those solutions worked for me. Found a workaround on MSDN

  1. Start Visual Studio.
  2. File -> Open Project.
  3. Point it at "C:\Windows\system32\cscript.exe" (or wherever your windows install directory is).
  4. When you get the elevation permissions dialog, click 'Ignore'.
  5. Go to project properties on the cscript.exe node.
  6. In arguments add '//d '.
  7. In 'Debugger type' change it to script.
  8. Close project properties.
  9. Hit F10.
Pokpoke answered 8/5, 2018 at 18:42 Comment(3)
I followed this but it did not work. It ends with message: "unable to start program #path_to_cscript# Debugger is not properly installed". I believe this might have something to do with the fact, that in VS->debug->options->debugging->just-in-time , there are just "native" and "managed" options. I cannot see the "script" option. I already tried to reinstall VS, restart computer etc.. Do you see the "script" option for Just-in-time debugger options?Helsell
this worked for me in VS2019 (as long as I put a path to my script file in Arguments as well). also you can use Add Existing Project to not have to create a brand new solution.Union
well... it almost works. VS seems to have issues since the file is locked while executing or something, not sure. it constantly wants to save the solution, and freezes every few lines for ~1min at a time while debugging. maybe it does need its own solution.Union
M
4

Please run your VS2017 as the admin, and then enable the script option under TOOLS->Options->Debugging->Just-In-Time, and then re-debug it again.

enter image description here

Even if I didn't use the VS2017 community version, but I get the same issue, I found that it was related to the JIT debugging in my side using VS2017 Enterprise version and it works well after I enable it:

enter image description here

Mears answered 29/5, 2017 at 5:39 Comment(1)
Seems like this option is not available in community edition of Visual Studio 2017Asmara
P
2

CSCript.exe requires double-forward-slashes for its own command-line options, because single-slashed arguments are passed to the script itself.

You want cscript.exe //X not cscript /X.

I also suggest the //D argument so it breaks immediately.

Pshaw answered 28/5, 2017 at 10:55 Comment(2)
sorry, fogotten to mention that I tried double-slashes too.Frontal
That's not quite true. They only need to be doubled if they follow the script filename. This is useful when using associative launches, e.g. myscript.vbs //B instead of cscript /B myscript.vbs.Dolores

© 2022 - 2024 — McMap. All rights reserved.