Back to Blog

Open Multiple Windows System Files With One Click

Assumptions:

1. You are on a windows platform.
2. You have Windows Scripting (WSH) enabled.
3. You have no security issues running VBS scripts.

The following code will pull up several system files in notepad all in one place. Save this code into a text file and then rename the extension to .vbs for it to become executable. Modify it to take out or add more by changing what is in the array. For example, taking out everything except the hosts file from the array will mean only the hosts file will be opened in notepad:

Set Sh = WScript.CreateObject("WScript.Shell")

On Error Resume Next

sOStype = Sh.RegRead(_
  "HKLM\SYSTEM\CurrentControlSet\Control\ProductOptions\ProductType")

If Err.Number <> 0 Then
  Wscript.Echo " This doesn't appear to be an NT-like operating system;" _
  & vbcrlf & "on Win9x use sysedit or msconfig."
Else
  Set FSO = CreateObject("Scripting.FileSystemObject")
  dirConfPath = "%SYSTEMROOT%\System32\"
  fileset=Array("config.nt","autoexec.nt","drivers\etc\hosts", _
    "drivers\etc\lmhosts","drivers\etc\networks", _
     "drivers\etc\protocol","drivers\etc\services")

  On Error Resume Next
  For Each configfile In fileset
    Sh.Run "Notepad " & dirConfPath & configfile
  Next
End If

 

Back to Blog