How to automatically set Remote path to the correct dacharts folder using SnagIt.

I had to manually change the Remote Path as shown in Fig 1.0 to the correct dacharts folder everyday. If I forget to set the correct path and save the settings, the posted images end up in the wrong folder.

Fig 1.0

This is what I came up with. The idea is to find the registry key called InetOutputDir under the profile that you are using for dacharts and change the value everytime the scripts gets executed before SnagIt starts. There are 4 things that you need to check and correct before this setup can work. 1) The first is to assign the correct registry key based on the Profile that you had created to the variable strKeyPath. Find the correct registry by running regedit from the command prompt and finding the key as illustrated in Fig 1.1

Fig 1.1

strKeyPath = "Software\TechSmith\SnagIt\8\Profiles\{9F6AFE32-26C8-4101-879C-38F0DC34C073}"

2) Set the correct location to the SnagIt Exe to the strExe variable

3) I have Windows Script runtime installed. The link at the time of writing this document is http://www.microsoft.com/downloads/details.aspx?FamilyID=0a8a18f6-249c-4a72-bfcf-fc6af26dc390&displaylang=en.

Tip: You may google for VBScript Scripting Runtime Download

4) The script below uses WMI (Windows Management Instrumentation- http://www.microsoft.com/whdc/system/pnppwr/wmi/default.mspx). You may need to check if the version of Windows you have installed supports. I have tested this only on Windows XP W/ SP2 and SnagIt version 8.0

Steps

1) I opened notepad and created a text file with the following lines of code.

On Error Resume Next

Dim strYear, strMonth, strDay, strDate

Dim objWMIService, objProcess

Dim strShell, strComputer, strExe, strInput

CONST HKEY_CURRENT_USER = &H80000001

Const SW_SHOWMINIMIZED = 2 ' Activates the window, and displays it as a minimized window.

strYear = Year(Date)

strMonth = Month(Date)

strDay = Day(Date)

If Len(strMonth) = 1 Then

strMonth = "0" & strMonth

End If

if Len(strDay) = 1 Then

strDay = "0" & strDay

End If

strDate = strYear & "-" & strMonth & "-" & strDay

strComputer = "."

Set StdOut = WScript.StdOut

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _

strComputer & "\root\default:StdRegProv")

strKeyPath = "Software\TechSmith\SnagIt\8\Profiles\{9F6AFE32-26C8-4101-879C-38F0DC34C073}"

strValueName = "InetOutputDir"

oReg.SetStringValue HKEY_CURRENT_USER, strKeyPath, strValueName, strDate

strExe = "C:\Program Files\TechSmith\SnagIt 8\SnagIt32.exe"

' Connect to WMI

set objWMIService = getobject("winmgmts://" & strComputer & "/root/cimv2")

' Obtain the Win32_Process class of object.

Set objProcess = objWMIService.Get("Win32_Process")

Set objStartup = objWMIService.Get("Win32_ProcessStartup")

Set objConfig = objStartup.SpawnInstance_

objConfig.ShowWindow = SW_SHOWMINIMIZED

'Execute the program now at the command line.

errReturn = objProcess.Create (strExe , null, objConfig, intProcessID)

2) Save the file as SnagItMyProfile.vbs in the SnagIt Folder “C:\Program Files\TechSmith\”. This is my default installation path and this could differ based on your installation path. If the path differs then change the following line of code to point to the correct exe.

strExe = "C:\Program Files\TechSmith\SnagIt 8\SnagIt32.exe"

Tip. You can go to Start -> Program -> Startup -> Right Click on SnagIt and click on Properties, then copy the text in the Target textbox as shown in Fig 1.2

Fig 1.2

3) You can copy the .vbs file that we just created and click on Start à Programs à Startup à Right click and then paste the shortcut here. Go to Start àProgram àStartup àRight Click on SnagIt and click on Properties. You will see the screen as shown in Fig 1.2. Change the Target to the SnagItMyProfile.vbs file including the full path. Change the start in directory as required. I did change it. The finished setup should look the screen shown in Fig 1.3.

4). If you take the option 1 in Step 3, then remember to delete the shortcut to the snagit executable.

4). Click on the OK button.

When you restart your computer the next day, as soon as you login, the Visual Basic script file that we created will get executed instead of the standard SnagIt application. The script File will attempt to change the Remote Path registry key and then start SnagIt.

The only problem is when the day rolls over into the next day when you are still logged in. There is no solution to this, but a workaround is to Close SnagIt and the rerun using the SnagIt shortcut in the StartUp group that we setup.

This is the completed script file for your reference.

Disclaimer: Please use this script at your own Risk. Editing the Registry etc is not recommended for normal users. You may want to take a backup of the Registry before attempting to run this script if you do not understand what the code does.

Submitted by AV

Last updated 06/11/2007