PrimalScript 2018 Not Allowing 64 bit Debug on VBS Scripts

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 5 years and 8 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
TheCruzer
Posts: 8
Last visit: Sat Mar 16, 2024 5:45 pm

PrimalScript 2018 Not Allowing 64 bit Debug on VBS Scripts

Post by TheCruzer »

To help you better we need some information from you.

*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***

Product, version and build: PrimalScript 2018 (Version 7.4.113)
32 or 64 bit version of product: 64-bit
Operating system: Windows 10 (Version 1709 - OS Build 16299.431)
32 or 64 bit OS: 64-bit

*** Please add details and screenshots as needed below. ***

Issue: When attempting to debug a VBS script with PrimalScript set to 'Local Machine 64 Bit' mode, PrimalScript does not go into debug mode. The screen display flashes for a moment and then returns to normal (and nothing appears in the Output window). When I reconfigure it to 'Local Machine 32 bit' mode, I can debug without issue.

I'm updating a VBS script which needs to make decisions based on the current 32 or 64 bit environment, so I need to launch and debug in both.

Notes: 'Running' a VBS script within PrimalScript in either 32 bit or 64 bit mode works fine and a sample VBS script which displays the operating environment it executes in is correctly validating the 32/64 execution mode. Launching PrimalScript as Administrator makes no difference. Launching debug elevated (Go - Debug elevated) also makes no difference. Both the local Administrators security group (my account is a member) as well as my account (directly) have local 'Debug programs' user rights (I thought I'd try that... it made no difference). As well, I created a similar PowerShell script and it correctly displays whether it is executing (using PoSH v5 ) in Run mode and in Debug modes for both of the 32 and 64 bit modes.

Ideas?

TheCruzer
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: PrimalScript 2018 Not Allowing 64 bit Debug on VBS Scripts

Post by Alexander Riedel »

PowerShell and VBScript debuggers are different animals and have no influence on each other.
Launching as administrator also has absolutely no bearing on the ability to debug (or not)
A quick test here shows no problem debugging VBScript files in 32 or 64 bit mode, so it might be a simple installation issue.
Look in this folder: C:\Program Files\Common Files\SAPIEN Common
for a file 'PrimalHost64.dll'
Does that exist?
If so open an elevated cmd prompt:
regsvr32 PrimalHost64.dll

Does that produce any errors?
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
TheCruzer
Posts: 8
Last visit: Sat Mar 16, 2024 5:45 pm

Re: PrimalScript 2018 Not Allowing 64 bit Debug on VBS Scripts

Post by TheCruzer »

Look in this folder: C:\Program Files\Common Files\SAPIEN Common for a file 'PrimalHost64.dll'
Does that exist?

Yes it does...

If so open an elevated cmd prompt: regsvr32 PrimalHost64.dll

I re-registered the dll. There is no change in behavior. Any other thoughts?

The Cruzer
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: PrimalScript 2018 Not Allowing 64 bit Debug on VBS Scripts

Post by Alexander Riedel »

Uninstall and re-install. Could be some other component. If it is, that would fix it.
Did this ever work before on that machine?
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
TheCruzer
Posts: 8
Last visit: Sat Mar 16, 2024 5:45 pm

Re: PrimalScript 2018 Not Allowing 64 bit Debug on VBS Scripts

Post by TheCruzer »

Uninstall and re-install. Could be some other component. If it is, that would fix it.

I uninstalled and re-installed PrimalScript 2018. There is no change in behavior. [Just in case, I also disabled all elements of McAfee Endpoint Security during the removal/re-installation.] The VBS script is still not going into debug mode when PrimalScript 2018 is set to 'Local Machine 64 Bit' mode.

Did this ever work before on that machine?

I previously had PrimalScript 2012 installed on this device, but haven't needed to do any VBS debugging in several years. So the feature was never tested on this particular OS/ Dell hardware device. I'm mostly using PowerShell these days.

On another note: These activities have all been occurring on my company device. I decided to perform an independent test and install on a personal device (HP Spectre x360) to see whether I could duplicate the behavior.

Product, version and build: PrimalScript 2018 (Version 7.4.113)
32 or 64 bit version of product: 64-bit
Operating system: Windows 10 Pro (Version 1803 - OS Build 17134.48)
32 or 64 bit OS: 64-bit

After installing PrimalScript 2018 and attempting to debug the same script in 'Local Machine 64 Bit' mode. I was able to duplicate the behavior. It goes into debug mode when in 32 bit mode, but NOT when it is in 64 bit mode. Here is the sample test script I'm using for this testing:

  1. Dim ExecutionMode
  2. Dim OSMode
  3.  
  4. Set WshShell       = CreateObject("WScript.Shell")
  5. Set WshProccessEnv = WshShell.Environment("Process")
  6. ExecutionMode      = WshProccessEnv("Processor_Architecture")
  7. OSMode             = WshShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE")
  8.  
  9. WScript.Echo "========================================================="
  10. WScript.Echo "Process Mode: " & ExecutionMode
  11. WScript.Echo "OS Type     : " & OSMode
  12. WScript.Echo "========================================================="
  13.  
The output when 'Run' in Local Machine 64 bit mode is:
  1. Microsoft (R) Windows Script Host Version 5.812
  2. Copyright (C) Microsoft Corporation. All rights reserved.
  3.  
  4. =========================================================
  5. Process Mode: AMD64
  6. OS Type     : AMD64
  7. =========================================================
  8. Execution time: 00:00:01
  9. Exit code: 0 , 0000h
The output when run in Local Machine 32 bit mode is:
  1. Microsoft (R) Windows Script Host Version 5.812
  2. Copyright (C) Microsoft Corporation. All rights reserved.
  3.  
  4. =========================================================
  5. Process Mode: x86
  6. OS Type     : AMD64
  7. =========================================================
  8. Execution time: 00:00:01
Exit code: 0 , 0000h

I'm open to any other ideas here.
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: PrimalScript 2018 Not Allowing 64 bit Debug on VBS Scripts

Post by Alexander Riedel »

Created the script, saved it, set a breakpoint and it works like a charm.
2018-06-08_14-21-49.png
2018-06-08_14-21-49.png (461.2 KiB) Viewed 4546 times
Not sure what could be the reason.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
TheCruzer
Posts: 8
Last visit: Sat Mar 16, 2024 5:45 pm

Re: PrimalScript 2018 Not Allowing 64 bit Debug on VBS Scripts

Post by TheCruzer »

=======================
I found the problem!

The SAPIEN executable named C:\Program Files (x86)\Common Files\SAPIEN Debugger 2018\scriptdriver64.exe has an apparent dependency on the PowerShell v2 Feature being installed. I'll say this right up front, it is now a modern security practice to require that PowerShell v2 be disabled when more modern versions are installed. This is because the new versions of PowerShell have built-in security Auditing features that older versions do not. On both of my systems, PowerShell v5.x is installed and PowerShell v2 was disabled following the noted best practice.

As you'll recall, I encountered the issue on my work laptop as well as on my personal device. Using the PowerShell AutoLab modules, I setup a Hyper-V based virtual environment to perform a clean Windows 10 OS test. I installed the trial version of PrimalScript 2018 on the Win 10 virtual device, copied over the test script and, tada, I was successful running a debug session with PrimalScript set to 'Local Machine 64 bit' mode.

That meant there was something different between my two laptops and the 'clean' virtual device. I installed Sysinternals Process Monitor on the virtual Win 10 device and captured a trace of a successful debug session. I repeated that on my personal device, capturing a failure. It took awhile looking at the traces side-by-side, but I was able to identify the place where one continued and the other skipped out. At the point in question, scriptdriver64.exe is performing a RegOpenKey READ operation on HKLM\SOFTWARE\Microsoft\PowerShell\1\PowerShellEngine (a reference to the PoSH v2 feature set). The Process Monitor traces showed a SUCCESS on the good debug test on the virtual Win 10 device and a NAME NOT FOUND on my local device where the 64 bit debug process against the VBS script was failing.
2018-06-09_Good_Debug.jpg
2018-06-09_Good_Debug.jpg (427.86 KiB) Viewed 4486 times
2018-06-09_No_Debug.jpg
2018-06-09_No_Debug.jpg (574.68 KiB) Viewed 4486 times
To attempt to test the solution, I reinstalled the PoSH v2 Feature (no reboots or logoffs required... I didn't even have to reload PrimalScript which was already running) and voila, I was finally successful in running 64 bit debug sessions. [I also noticed that, for the first time since running this new version of PrimalScript, I had variables automatically appearing in the Variables window.] The resolution has worked for both of my devices.

I'm not sure why there is a tie-in between debugging VBS scripts and the PowerShell v2 feature, but there you go.

I would ask that SAPIEN consider this a bug in PrimalScript and take the appropriate action. I look forward to a resolution in the near future. Due to corporate policy, the PowerShell V2 Feature on all our devices is not supposed to be installed.

TheCruzer
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: PrimalScript 2018 Not Allowing 64 bit Debug on VBS Scripts

Post by Alexander Riedel »

I will investigate. There should not be any dependency on PowerShell V2 being installed. If that is indeed the case it will be removed. As you correctly state this would be a bug. Please stand by.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: PrimalScript 2018 Not Allowing 64 bit Debug on VBS Scripts

Post by Alexander Riedel »

There is some old setting that would on demand connect the VBScript debugger to the ActiveX Powershell host. It should not be active and would also apply to 32 bit, but it would explain what you see.
So I am attaching a version of scriptdebugger64.dll with that particular stretch of code removed to see if that fixes your problem.

Please let us know if you have a chance to check that out.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
TheCruzer
Posts: 8
Last visit: Sat Mar 16, 2024 5:45 pm

Re: PrimalScript 2018 Not Allowing 64 bit Debug on VBS Scripts

Post by TheCruzer »

I found the folder where ScriptDebugger64.dll resides (C:\Program Files (x86)\Common Files\SAPIEN Debugger 2018). I renamed the original and copied in the replacement to test. I still have the PoSH v2 feature installed, so debugging in 64 bit mode 'should' still be working and I wanted to test the new DLL before removing PoSH v2. I launched PrimalScript 2018 without issue and I loaded the test VBS script. I set a breakpoint, launched Go to debug and there was an immediate error. I closed the dialog and PrimalScript did not crash. Did I miss a step?
2018-06-11_Debugger_Error.jpg
2018-06-11_Debugger_Error.jpg (31.37 KiB) Viewed 4401 times
[Note: I restored the original ScriptDebugger64.dll file and things went back to normal while debugging with 64 bit mode + PoSH v2 in place.]
This topic is 5 years and 8 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.