Jump to content

Select (Run) Application from the Start button


dew
 Share

Recommended Posts

I need a way to start all applications lnk's in the start menu works.

I would like to know the best way to do this, and how.

Basically, I need the following:

1. Get the *.lnk's files in the Start Menu (best way to do this?)

2. Verify the *.lnk's opens correctly (run)

3. Close the application (fastest way - (Alt-F4?) or ?)

4. Logged the information ( *.lnk pass/fail)

thanks ahead

Link to comment
Share on other sites

This would have been easy to find out using the forum search in combination with the helpfile so normally I'd say RTFM! But as I have my good day today :)

;===========================
;Startmenu Integrity Checker
;===========================
;Author:    tannerli
;Date:      20.1.09

Dim $log, $dir, $fullfile, $lnkinfo


;Open the logfile:
$log = FileOpen("lnktest.log", 2) ;Caution: Log will be erased at start!

_loopdir(@StartMenuDir) ;Will find all files in the current users's startmenu, use @StartMenuCommonDir for the allusers startmenu

Func _loopdir($dir)
    $search = FileFindFirstFile($dir & "\*") 

    While 1
        $file = FileFindNextFile($search)
        If @error Then ExitLoop     
        
        $fullfile = $dir & "\" & $file

        If StringInStr(FileGetAttrib($fullfile), "D") Then _loopdir($fullfile) ;If its a subdirectory, check this too
        
        If StringLower(StringRight($file, 3)) = "lnk" Then ;Check wheter it is a lnk based on file extension
            $lnkinfo = FileGetShortcut($fullfile)
            If Not FileExists($lnkinfo[0]) Then ;Check wheter target is existing
                FileWriteLine($log, $fullfile & ": Invalid target!")
            Else
                FileWriteLine($log, $fullfile & ": Passed")
            EndIf
        EndIf
    WEnd
EndFunc

I hope this will help

Link to comment
Share on other sites

This would have been easy to find out using the forum search in combination with the helpfile so normally I'd say RTFM! But as I have my good day today :)

;===========================
;Startmenu Integrity Checker
;===========================
;Author:    tannerli
;Date:      20.1.09

Dim $log, $dir, $fullfile, $lnkinfo


;Open the logfile:
$log = FileOpen("lnktest.log", 2) ;Caution: Log will be erased at start!

_loopdir(@StartMenuDir) ;Will find all files in the current users's startmenu, use @StartMenuCommonDir for the allusers startmenu

Func _loopdir($dir)
    $search = FileFindFirstFile($dir & "\*") 

    While 1
        $file = FileFindNextFile($search)
        If @error Then ExitLoop     
        
        $fullfile = $dir & "\" & $file

        If StringInStr(FileGetAttrib($fullfile), "D") Then _loopdir($fullfile) ;If its a subdirectory, check this too
        
        If StringLower(StringRight($file, 3)) = "lnk" Then ;Check wheter it is a lnk based on file extension
            $lnkinfo = FileGetShortcut($fullfile)
            If Not FileExists($lnkinfo[0]) Then ;Check wheter target is existing
                FileWriteLine($log, $fullfile & ": Invalid target!")
            Else
                FileWriteLine($log, $fullfile & ": Passed")
            EndIf
        EndIf
    WEnd
EndFunc

I hope this will help

Thank you, I guess I did all my searching in the wrong area. It does do the job! I will study the routine "(@StartMenuDir)" you used and will learn how it works. Thanks again.
Link to comment
Share on other sites

Thank you, I guess I did all my searching in the wrong area. It does do the job! I will study the routine "(@StartMenuDir)" you used and will learn how it works. Thanks again.

It really does it nicely - thanks for showing me how.

Now I am trying to use the log file (removed :pass / invalid statements) to actually run the file.

It should be easy, but being new I'll hack at it.

thanks again.

Link to comment
Share on other sites

It really does it nicely - thanks for showing me how.

Now I am trying to use the log file (removed :pass / invalid statements) to actually run the file.

It should be easy, but being new I'll hack at it.

thanks again.

Hey here's another way to go about it..

$mFile = FileOpen("c:\lnkfiles.txt", 2)

$var = DriveGetDrive( "FIXED" )

local $uArray, $iStdoutg, $sTemp, $placeholder,$sFolder,$tSort

$search=(@StartMenuDir & "\*.lnk")

$search1=(@StartMenuCommonDir & "\*.lnk")

FileSearch($search)

FileSearch($search1)

FileClose($mFile)

Func Filesearch($var)

$iStdoutg = Run(@comspec & ' /C cd ..\..\..\..\.. & dir "' & $var& '" /A /B /O:' & $tSort & ' /S', @workingdir, _

@SW_HIDE, 6)

While 1

$line = StdoutRead($iStdoutg)

If @error Then ExitLoop

If $line <> "" then

FileWriteLine($mFile,$line)

EndIf

Wend

EndFunc

You will also have to look in the "@startmenucommondir" location for the lnk files.

This will generate the list of link files with their locations. Simply put them in run.

now, check the "ProcessExists" when u run each file to really see if the lnk is launched.

Next use "ProcessKill" or "processClose" and ProcessWaitClose. To terminate the application.

Cheers,

[font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com
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...