Thursday, October 2, 2014

View source code quickly with windows preview


If you want to view your source code in windows preview you will need to add two items to the registry entry for that file type.  Open your registry editor (window key+R, regedit.exe) and find the class definition for your file type.  In the registry editor it will be under Computer\HKEY_CLASSES_ROOT\.  The example I'm using is for Progress 4GL .p source code files.


Then you will need to add a string named "Content Type" with a value of text/plain and another string named "PerceivedType" with a value of text.

Now you can see your code in the preview window.

Thursday, June 26, 2014

How to enable VNC through Windows 7 firewall from the command line.

This command opens the firewall for VNC.  You may have to modify the program= and profile= options if you are using a different network type or version of VNC.

netsh advfirewall firewall add rule name=VNC dir=in action=allow program="C:\Program Files\uvnc bvba\UltraVnc\winvnc.exe"  description="Incoming VNC" enable=yes profile=domain protocol=any

Stop and disable the Bonjour service from the command line.

I have found that in some instances the Bonjour service really messes up network browsing.  Here's how to stop it and disable it from the command line.

To stop:
net stop "bonjour service"

To disable the service:
sc config "bonjour service" start= disabled

Friday, October 25, 2013

VBS Script to play random Halloween sounds at random intervals within a 10 minute window.

 This has been tested with Windows 7 and XP.
  1. You will need to download and install SMPlayer in "C:\Program Files\SMPlayer".
  2. You will need to get your own Halloween sound files and place them in a folder (minimum of 4 files).
  3. Save this script as "Halloween.vbs".  Edit the path to your files.
  4. Double-click the script file to run it.
'This program was written by Brian A. Hart
'10/25/2013
'This programs automatically plays or displays each file in the
'C:\Temp\Halloween folder
'It will not repeat the last 3 played

Dim fso, folder, files, WshShell, Return, FileCount, FileList(), FileNum, RandFile, PlayList(2), Played
 
'Get the folder info
Set WshShell = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder("C:\Temp\Halloween\")  'EDIT THIS!


'run the file(s) randomly
Randomize 'Init random number generator
do while true = true

    'load the files into the FileList array
    'We do this each time in case there are new files
    Set files = folder.Files
    ReDim FileList(CInt(files.Count - 1), 2)
    FileCount = 0
    for each folderIdx in files
        'load the file path/name
        FileList(FileCount, 0) = folderIdx.ParentFolder
        'load the file type
        FileList(FileCount, 1) = folderIdx.Type
        'load the short path
        FileList(FileCount, 2) = folderIdx.Name
        FileCount = FileCount + 1
        'msgbox(folderIdx.Type)
    next
   
    'Pick a random file
    RandFile = Int(((files.Count - 1) * Rnd) + 1)
    'msgbox(FileList(RandFile, 0) & " " & FileList(RandFile, 2))

    'Don't repeat the last three
    Do while InStr("," & Join(PlayList, ",") & ",", "," & RandFile & ",")
        RandFile = Int(((files.Count - 1) * Rnd) + 1)
        'msgbox(FileList(RandFile, 0) & chr(10) & RandFile & "-|-" & "," & Join(PlayList, ",") & "," & chr(10) & InStr("," & Join(PlayList, ",") & ",", "," & RandFile & ","))
    Loop

    'Run the file we picked
    Played = False
   
    'don't play if the file is locked
    'msgbox(fso.FileExists(FileList(RandFile, 0) & "\~$" & FileList(RandFile, 2)))
    if not (fso.FileExists(FileList(RandFile, 0) & "\~$" & FileList(RandFile, 2))) and not (Left(FileList(RandFile, 2),2)="~$") then
   
        'Is it MP3? (win 7)
        if FileList(RandFile, 1) = "MP3 Format Sound" then
            Set CmdExec = WshShell.Exec("C:\Program Files\SMPlayer\mplayer\mplayer.exe -really-quiet -fs " & """" & FileList(RandFile, 0) & "\" & FileList(RandFile, 2) & """")
            Do While CmdExec.Status = 0
                Wscript.Sleep 100
            Loop
            Played = True
        end if
       
        'Is it MP3? (win XP)
        if FileList(RandFile, 1) = "MP3 audio file (mp3)" then
            Set CmdExec = WshShell.Exec("C:\Program Files\SMPlayer\mplayer\mplayer.exe -really-quiet -fs " & """" & FileList(RandFile, 0) & "\" & FileList(RandFile, 2) & """")
            Do While CmdExec.Status = 0
                Wscript.Sleep 100
            Loop
            Played = True
        end if       
       
        'Is it Wave? (win 7 and XP)
        if FileList(RandFile, 1) = "Wave Sound" then
            Set CmdExec = WshShell.Exec("C:\Program Files\SMPlayer\mplayer\mplayer.exe -really-quiet -fs " & """" & FileList(RandFile, 0) & "\" & FileList(RandFile, 2) & """")
            Do While CmdExec.Status = 0
                Wscript.Sleep 100
            Loop
            Played = True
        end if
       
    end if 'locked?

    set CmdExec = Nothing

    if Played then
        'Keep track of the last 3 we played
        PlayList(0) = PlayList(1)
        PlayList(1) = PlayList(2)
        PlayList(2) = RandFile
    end if
   
    Randomize
    RandTime = Int(((600000 - 1) * Rnd) + 1)
    WScript.Sleep RandTime
Loop