Skip to content

Instantly share code, notes, and snippets.

@willblatt
Created July 2, 2016 19:03
Show Gist options
  • Save willblatt/eba7557a71b4a7151bc113979dd58014 to your computer and use it in GitHub Desktop.
Save willblatt/eba7557a71b4a7151bc113979dd58014 to your computer and use it in GitHub Desktop.
Surpac startup script
Option Explicit
Dim strPath
Dim shortCutPath
Dim rootDir
' path to the shortcut without the ".lnk" extension
shortCutPath = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\GEOVIA\GEOVIA Surpac 6.7.1 (x64)"
' The highest level directory in the dialog (change to blank for My Computer)
rootDir = "C:\BlattBros\Projects"
'*****************No changes below this point************************************
strPath = SelectFolder(rootDir)
If strPath = vbNull Then
Else
Dim sh
Dim shortcut
Dim ws
Set sh = CreateObject("WScript.Shell")
Set shortcut = sh.CreateShortcut(shortCutPath & ".lnk")
shortcut.WorkingDirectory = strPath
shortcut.Save
Set ws = WScript.CreateObject("WScript.Shell")
ws.Run Chr(34) & shortCutPath & Chr(34)
End If
Function SelectFolder(myStartFolder)
' This function opens a "Select Folder" dialog and will
' return the fully qualified path of the selected folder
'
' Argument:
' myStartFolder [string] the root folder where you can start browsing;
' if an empty string is used, browsing starts
' on the local computer
'
' Returns:
' A string containing the fully qualified path of the selected folder
'
' Written by Rob van der Woude
' http://www.robvanderwoude.com
' Standard housekeeping
Dim objFolder, objItem, objShell
' Custom error handling
On Error Resume Next
SelectFolder = vbNull
' Create a dialog object
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder(0, "Select the Surpac Working Directory", 0, myStartFolder)
' Return the path of the selected folder
If IsObject(objfolder) Then SelectFolder = objFolder.Self.Path
' Standard housekeeping
Set objFolder = Nothing
Set objshell = Nothing
On Error Goto 0
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment