Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: .bat file association  (Read 3865 times)

0 Members and 1 Guest are viewing this topic.

Edgecrusher22

    Topic Starter


    Newbie
    • Experience: Familiar
    • OS: Windows 7
    .bat file association
    « on: September 26, 2011, 12:43:22 PM »
    Hey everybody, this is a general question about .bat files that has never come up before for me.

    I have an encryption program set up at work that uses the .pgp encryption format. I open these by using a .bat file to de-encrypt them that has instructions and links to my encryption keys. I recently upgraded my workstation from an XP system to a Win7 system. I used to be able to double click the .pgp file and the dycryption program would run automatically (in fact there are still XP computers on the network that continue to work this way). On my windows 7 system this no longer works. I tried setting the association of .pgp files to the .bat file I use, but it will just not accept it as a default program for opening. I can still drag and drop the encrypted files into the .bat and it runs like normal which indicates to me that the .bat is fine and working correctly. It's not a huge hassel but i just found it odd that i can no longer do it the old way. Could this just be a win7 quirk or am I not seeing something?

    Thanks for any help!
    Edgecrusher22

    patio

    • Moderator


    • Genius
    • Maud' Dib
    • Thanked: 1769
      • Yes
    • Experience: Beginner
    • OS: Windows 7
    Re: .bat file association
    « Reply #1 on: September 26, 2011, 12:49:18 PM »
    Post the .bat file...
    " Anyone who goes to a psychiatrist should have his head examined. "

    Edgecrusher22

      Topic Starter


      Newbie
      • Experience: Familiar
      • OS: Windows 7
      Re: .bat file association
      « Reply #2 on: September 26, 2011, 12:58:24 PM »
      ok here is the .bat I **** out the password for our system and mel and alice are just server names at this location. I don't see anything wrong and like I said it works fine if you drop the encrypted files into it. I just can't get it to associate with the incoming encrypted files for double-click opening purposes seems more like a windows issue rather than a .bat issue. 

      @echo off
      setlocal ENABLEDELAYEDEXPANSION
      REM This File is used by scheduled tasks and should not be deleted!!!
      REM
      REM Usage: decrypt.bat (output file) (input file)
      REM Example:  decrypt.bat final.pgp final.txt
      REM   This example shows how to encrypt a file called final.txt
      REM   and create a final output file named final.pgp.
      REM   This script assumes that the password is **********.
      echo %date% %time% Decryption of %2 to %1 >> \\mel\gpg\scripts\log.txt
      echo *******************************
      echo  BEGINNING DECRYPTION OF FILE
      echo *******************************
      Set var1=**********

      path \\alice\dfs\cygwin\bin;%path%

      if .%2==. (
        set infile=%~1
        set outfile=!infile:.pgp=!
        set outfile=!outfile:.gpg=!
      ) else (
        set infile=%~2
        set outfile=%~1
      )
      echo infile= %infile%
      echo outfile=%outfile%

      echo %var1%|\\mel\gpg\gpg --homedir=\\mel\gpg --batch --yes --passphrase-fd 0 -o "%outfile%" --decrypt "%infile%"

      rem Inspect file to see if it's a tar file.
      file "%outfile%" |grep -q "POSIX tar archive"
      if errorlevel 1 goto :NotTar
      echo *******************************
      echo  Decrypted file is a TAR archive; expanding ..
      echo *******************************
      echo on
      pushd "%outfile%\.."
      tar -xvf "%outfile%" --force-local && del "%outfile%"
      popd
      pause

      :NotTar
      echo *******************************
      echo  FILE DECRYPTION COMPLETE...
      echo *******************************

      endlocal