All posts by admin

How Thor checks and distributes new versions of tools in FoxPro

In this post I will explain how Thor checks for new version and distributes tools from VFPx community like GoFish, FoxCharts, FoxyPreviewer, etc.  I was involved with Jim Nelson at a pretty low level when all this distribute/update goodness for FoxPro via Thor was first being developed. I have emails dates October 2011 where we were working on this, so 6 years ago as of this post in October 2017.

First, look in the Thor Updates folder of your Thor installation. On my machine the Path is:

C:\Fox\Utils\Thor\Thor\Tools\Updates

In this folder, you will find an updater prg for each tool that is available from Thor. In this case, for the FoxyPreviewer app:

Now, open that file and have a look… In this file, you will see it contains all the info that the Thor update engine uses to check for updates and download a tool.

In this case, the current version that Thor publishes ver ‘v2.99z30’ and it pulls the zip file from this website, which is owned by Rick Schummer, and Jim Nelson (along with a few others I think) have FTP access to this server to post the latest ZIP file.

ZIP location:

So, to get a tool updated, Jim has to do 2 things:

1. Distribute an updated updater prg which will be pulled down when the user from Thor Check For Update. So, he sends out an updates Thor_Update_<<ToolName>>.prg with the new version number and file location on the server. User will see available updates in the CFU grid.

2. He must also post the referenced ZIP file to the server at the path referenced in the updater prg.

With these two things in place, lots a black magic happens (or, white magic, since it is Jim, and he is a good fella by most accounts), and users will see that a new update is available, and if Jim has been living right, it will download and unzip to the users local Tools or Components path in the Thor folder.

Here is the code in thor_Update_FoxyPreviewer.prg

 

 

Helpful Windows Admin Tips


To launch Windows Update from the Windows Run dialog:

ms-settings:windowsupdate


Use Powershell to kill processes with a name filter:

Get-Process | Where-Object {$_.Path -like "*SOME-FILTER*"} | Stop-Process


See what time computer was booted up:

net statistics server


Restart or Shut Down a Remote Computer and Document the Reason (https://technet.microsoft.com/en-us/library/cc770416(v=ws.11).aspx)

shutdown /i


 

Debugging Angular2 apps in Visual Studio Code

I couldn’t debug TypeScript from my Angular 2 app files at first…

but then I got it working. Here’s how:

(Note: The environment used here was Windows 10 and a beginner Angular 2 app cloned from the Angular Quick Start repo from the Angular Github repo. If you’re on a Mac or Linux system, I can’t say whether the solution presented he will work for those environments.)

This post explains my trouble (and solution) of using the the Microsoft VS Code Debugger for Chrome extension to debug my first beginner Angular 2 app from within VS Code.  I let VS Code create the default launch.json  file that is required (details in this link: https://code.visualstudio.com/docs/editor/debugging) , but when I started the debugger from inside VS Code, and I put a breakpoint on a line of code in a TypeScript file (.ts), VS Code complained that it could not find the corresponding .js file (therefore it could debug from the .ts file), and it put a little gray circle beside the line of code, instead of the typical red dot, with a warning:

“Breakpoint ignored because generated code not found (source map problem).”

When searching the web about this issue, all of the suggested launch.json code examples from various posts I found all looked very similar in what they suggested was required to fix the issue, but I never could get any of them to work for my app / dev environment. But, I finally found one that did work for my beginner Angular 2 project, which I had begun by cloning the Angular 2 Quick Start repo.

I found the magic solution for me in one user’s example that he posted to an issue on the VSCode GitHub project: https://github.com/Microsoft/vscode-chrome-debug/issues/367 and again the issue of where the generated .js and .js.map files are located (in a Windows environment) is addressed in this issue: https://github.com/angular/angular-cli/issues/1223

Now it works!

Here’s the part from his included code that worked for me:

IMPORTANT: Kill all current VS Code and Chome instances to start fresh.

After making this change to my launch.json, I made sure to kill all existing VS Code instances and all Chrome instances. Then I used npm start  and then I started the debugger from inside VS Code. It then launched its own instance of Chrome to start my app, and finally, VS Code debugger was able to trace into the .ts code because it was finally able to find the generated .js code.

.gitignore changes

I also found that I needed to add two folders to my .gitignore  file:

 

Configure Windows Defender using PowerShell

References

I found these 2 links very helpful and informative which explain how to use PowerShell commands to observe the current setting of Windows Defender and make configuration changes such as disabling and enabling, and how to add exclusions on certain apps.

#1

http://www.thomasmaurer.ch/2016/07/how-to-disable-and-configure-windows-defender-on-windows-server-2016-using-powershell/

#2

and this one, which has a short but helpful video: http://www.netometer.com/blog/?p=1579

Add Windows Defender exclusion for iBackup exe

In my case, I wanted to add an exclusion for the iBackup exe which runs nightly to do a local disk backup to another drive on the same machine, and Windows Defender was watching every file write operation in real time, and this made the backup take a very long time. So, I added an exclusion for the iBackup processes exe using this command, and it sped up the backup tremendously:

 

Manually update Windows Defender to fix update failures KB2267602 (Definition 1.213.6196.0) – Error 0x80070643

On a few of my Windows 10 computers, Windows Defender was failing to update properly through Windows Update.  I found that you can manually update Windows Defender using this command from a terminal window:

I found this instruction in the comments of this post: https://answers.microsoft.com/en-us/protect/forum/protect_defender-protect_updating/definition-update-for-windows-defender-kb2267602/d0d06c7a-fd70-4f27-94a6-9320d8114768

Set Windows local user account passwords to never expire

I found this helpful instruction from @hansb1 to prevent Windows local user account passwords to never expire:

Open a Command Prompt as the administrator mode, then run the following command:


Your password will never expire.

Thanks @hansb1!

You can see his answer given in a comment to this Bleeping Computer post: https://www.bleepingcomputer.com/forums/t/565081/cannot-set-password-never-expires-server-2012/

Sql Server queries using PowerShell – Lesson 1

It’s actually pretty easy to throw a SQL query against Sql Server using PowerShell.   This would be very familiar to any C# or FoxPro developer, so don’t let the mystery of Power Shell scare you away from exploring this handy tool.

Here’s a tiny code snippet to show you how simple it is:

powershell_screenshot_1_getting_started

Note that the call to the DoSql() function is a wrapper function that I wrote which creates a few PowerShell objects to do all the low level work so that you don’t have to repeat all that connection and plumbing stuff in your scripts. Once you have that in place, executing Sql queries is a piece of cake.  After you get back the query results, PowerShell has all the standard language features you’d expect such as looping and counting, and even some cool sorting and filtering tricks that are pretty handy for working with the data rows.

Helper functions

 

From here, it becomes really easy to add system admin things shooting off an email, or calling a Stored Proc, or writing a Windows Event log entry, or call an external API, or blah-blah-blah.

Every modern version of Windows has PowerShell pre-installed, and it even has a simple IDE (Called PowerShell ISE ) to give you a coding environment with intellisense, code completion, and debugging tools.

Note: I found this article very helpful in learning how to do this: https://cmatskas.com/execute-sql-query-with-powershell/