Skip to content

Instantly share code, notes, and snippets.

@operatorequals
Last active April 23, 2018 17:25
Show Gist options
  • Save operatorequals/366988e600f671ba08b0a334ece70cc4 to your computer and use it in GitHub Desktop.
Save operatorequals/366988e600f671ba08b0a334ece70cc4 to your computer and use it in GitHub Desktop.
VBS script to Auto Open Microsoft Word
Set shell = WScript.CreateObject("WScript.Shell")
' Looks for Microsoft Office Word Executable
Set resp = shell.exec("cmd.exe /c cd C:\\ && dir winword.exe /s/b ")
word = resp.StdOut.ReadAll()
' Modifies the path to not contain CRLF
segm = Split(word, vbcrlf)
' Creates the command to be run in shell
word = "cmd /c " & chr(34) & segm (0) & chr(34)
' Runs the shell object with the specified Exe Path
shell.exec( word )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment