Jump to content

Launching URL's and .lnk files with different app


Recommended Posts

I'm building a custom installer for DropMyRights and also to update the IE shortcuts on the Desktop, quickLaunch bar, and Start Menu to launch IE through DropMyRights, as well as an appropriate uninstall. That's all pretty easy but i'm having problems with one thing. How the heck to I update the registry so if a user clicks on a URL Shortcut that they may have on their desktop, or a URL in an email link to launch DropMyRights instead of IE directly.

Any Ideas?

Thanks,

Mike

Link to comment
Share on other sites

Hi.Really nice idea.Solution it works for me under WIN XP SP2.

It uses Image File Execution Registry key.

It must do what you want to do.

#RequireAdmin
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\myapps.exe")
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\myapps.exe","Debugger","REG_SZ","%homedrive%\yourlauncher.exe")


#cs

HERE IS myapps.exe your 'emetized application' in eg. iexplore.exe


#ce





#cs
CONTENT OF yourlauncher.exe

echo off
runas /user:DroppedRights /savecred:typepasswordhere "firefox.exe"

and then compile it to exe(bat2exe) or use runwait() for this batch scenario and just compile it to yourlauncher.exe and place to %homedrive%\
DroppedRights here my restricted user account
typepasswordhere    here valid password for DroppedRights account.
You need only in first launch type password.In other authorisations it didnt require manual typing of password because /savecred is for remember password.

#ce

EDIT:homedrive% => %homedrive%

EDIT: %homedrive%\yourlauncher.exe must be your actual another application for example firefox.exe

so when myapps.exe when executed it will execute => %homedrive%\yourlauncher.exe => firefox.exe

Edited by Fire
[size="5"] [/size]
Link to comment
Share on other sites

So, i ran into an issue where DropMyRights doesn't seem to allow passing command line arguments to the target exe. The creator posted the code for it on his blog and i'm wondering if anyone here is able to convert to AutoIT? http://msdn.microsoft.com/en-us/library/ms972827.aspx

//////////////////////////////////////////////////////////////////////////////////
DWORD wmain(int argc, wchar_t **argv) {

   DWORD fStatus = ERROR_SUCCESS;

   if (2 != argc && 3 != argc) {
      Usage();
      return ERROR_INVALID_PARAMETER;
   }

   // get the SAFER level
   DWORD hSaferLevel = SAFER_LEVELID_NORMALUSER;
   if (3 == argc && argv[2]) {
      switch(argv[2][0]) {
         case 'C' : 
         case 'c' :  hSaferLevel = SAFER_LEVELID_CONSTRAINED; 
                  break;
         case 'U' :
         case 'u' :   hSaferLevel = SAFER_LEVELID_UNTRUSTED;
                  break;

         default  :   hSaferLevel = SAFER_LEVELID_NORMALUSER;
                  break;
      }
   }

   // get the command line, and make sure it's not bogus
   wchar_t *wszPath = argv[1];
   size_t cchLen = 0;
   if (FAILED(StringCchLength(wszPath,MAX_PATH,&cchLen)))
      return ERROR_INVALID_PARAMETER;

    SAFER_LEVEL_HANDLE hAuthzLevel = NULL;
    if (SaferCreateLevel(SAFER_SCOPEID_USER,
                         hSaferLevel,
                         0, 
             &hAuthzLevel, NULL)) {

        //  Generate the restricted token we will use.
        HANDLE hToken = NULL;
        if (SaferComputeTokenFromLevel(
            hAuthzLevel,    // SAFER Level handle
            NULL,           // NULL is current thread token.
            &hToken,        // Target token
            0,              // No flags
            NULL)) {        // Reserved

         STARTUPINFO si;
         ZeroMemory(&si, sizeof(STARTUPINFO));
         si.cb = sizeof(STARTUPINFO);
         si.lpDesktop = NULL;
       
         // Spin up the new process
         PROCESS_INFORMATION pi;
         if (CreateProcessAsUser( 
            hToken,
            wszPath, NULL,
            NULL, NULL,
            FALSE, CREATE_NEW_CONSOLE,
            NULL, NULL,  
            &si, &pi)) {

               CloseHandle(pi.hProcess);
               CloseHandle(pi.hThread);

         } else {
            fStatus = GetLastError();
            fwprintf(stderr,L"CreateProcessAsUser failed (%lu)\n",fStatus);
         } 
      } else {
         fStatus = GetLastError();
      }

      SaferCloseLevel(hAuthzLevel);

   } else {
      fStatus = GetLastError();
   }

   return fStatus;
}
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...