PrimalScript 2018 Not Allowing 64 bit Debug on VBS Scripts

Support for all customers who have purchased a PrimalScript product license. This forum does not offer a response time guarantee.
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE 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.
User avatar
TheCruzer
Posts: 7
Joined: Sun Mar 03, 2013 12:40 pm

PrimalScript 2018 Not Allowing 64 bit Debug on VBS Scripts

Post by TheCruzer » Wed Jun 06, 2018 11:23 am

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: 6544
Joined: Tue May 29, 2007 4:43 pm

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

Post by Alexander Riedel » Wed Jun 06, 2018 1:26 pm

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: 7
Joined: Sun Mar 03, 2013 12:40 pm

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

Post by TheCruzer » Thu Jun 07, 2018 11:36 am

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: 6544
Joined: Tue May 29, 2007 4:43 pm

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

Post by Alexander Riedel » Thu Jun 07, 2018 12:44 pm

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: 7
Joined: Sun Mar 03, 2013 12:40 pm

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

Post by TheCruzer » Fri Jun 08, 2018 12:46 pm

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.  
  3. Dim OSMode
  4.  
  5.  
  6.  
  7. Set WshShell       = CreateObject("WScript.Shell")
  8.  
  9. Set WshProccessEnv = WshShell.Environment("Process")
  10.  
  11. ExecutionMode      = WshProccessEnv("Processor_Architecture")
  12.  
  13. OSMode             = WshShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE")
  14.  
  15.  
  16.  
  17. WScript.Echo "========================================================="
  18.  
  19. WScript.Echo "Process Mode: " & ExecutionMode
  20.  
  21. WScript.Echo "OS Type     : " & OSMode
  22.  
  23. WScript.Echo "========================================================="
  24.  
  25.  
The output when 'Run' in Local Machine 64 bit mode is:
  1. Microsoft (R) Windows Script Host Version 5.812
  2.  
  3. Copyright (C) Microsoft Corporation. All rights reserved.
  4.  
  5.  
  6.  
  7. =========================================================
  8.  
  9. Process Mode: AMD64
  10.  
  11. OS Type     : AMD64
  12.  
  13. =========================================================
  14.  
  15. Execution time: 00:00:01
  16.  
  17. 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.  
  3. Copyright (C) Microsoft Corporation. All rights reserved.
  4.  
  5.  
  6.  
  7. =========================================================
  8.  
  9. Process Mode: x86
  10.  
  11. OS Type     : AMD64
  12.  
  13. =========================================================
  14.  
  15. Execution time: 00:00:01
Exit code: 0 , 0000h

I'm open to any other ideas here.

User avatar
Alexander Riedel
Posts: 6544
Joined: Tue May 29, 2007 4:43 pm

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

Post by Alexander Riedel » Fri Jun 08, 2018 2:25 pm

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 244 times
Not sure what could be the reason.
Alexander Riedel
SAPIEN Technologies, Inc.

User avatar
TheCruzer
Posts: 7
Joined: Sun Mar 03, 2013 12:40 pm

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

Post by TheCruzer » Sat Jun 09, 2018 6:36 pm

=======================
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 184 times
2018-06-09_No_Debug.jpg
2018-06-09_No_Debug.jpg (574.68 KiB) Viewed 184 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: 6544
Joined: Tue May 29, 2007 4:43 pm

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

Post by Alexander Riedel » Sun Jun 10, 2018 6:06 am

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: 6544
Joined: Tue May 29, 2007 4:43 pm

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

Post by Alexander Riedel » Sun Jun 10, 2018 7:33 am

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: 7
Joined: Sun Mar 03, 2013 12:40 pm

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

Post by TheCruzer » Mon Jun 11, 2018 4:04 pm

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 99 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.]