WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Files and Directories

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Display a Files Property Sheet

 Keywords:  

Question:

How to display a files property sheet?

I tried:

ShellExecute
("filename.ext","","",@NORMAL,"properties")

I get nothing...is there a setting in Explorer?

I tried it with other files...

file = "C:\x\codex\Codex Arcanum Search.exe"
shellexecute(file,"","C:\x\codex\",@normal,"properties")
exit
Still nothing

Are there other opportunities in WinBatch to display a files property sheet?

Answer:

The ShellExecute trick only seems to work for shortcuts AND only if you keep the script running (WinWaitCLose, etc) otherwise windows will dismiss the properties box automatically.

I played with the "Shell.Application" object and the InvokeVerb Method resp. with the FileItemVerbs collection and had no luck with enumeration.

What I have so far is an udf like following, but I think, the effort is too much. Bloody display of property sheet might be a smaller routine.

Detlev Dalitz DD.20030130.0052

;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfDisplayPropertiesSheet (sFilename)

slpVerb="properties" ; verbs are "open", "print", "edit" etc.
hBBlpVerb=BinaryAlloc(StrLen(slpVerb)+1)
BinaryPokeStr(hBBlpVerb,0,slpVerb)
pBBlpVerb=IntControl(42,hBBlpVerb,0,0,0)

slpFile=sFilename
hBBlpFile=BinaryAlloc(StrLen(slpFile)+1)
BinaryPokeStr(hBBlpFile,0,slpFile)
pBBlpFile=IntControl(42,hBBlpFile,0,0,0)

SEE_MASK_INVOKEIDLIST   = 12   ; &HC
SEE_MASK_NOCLOSEPROCESS = 64   ; &H40
SEE_MASK_FLAG_NO_UI     = 1024 ; &H400
SW_SHOWNORMAL           = 1

hBBSEI=BinaryAlloc(60)
BinaryPoke4(hBBSEI,00,60)
BinaryPoke4(hBBSEI,04,SEE_MASK_INVOKEIDLIST|SEE_MASK_NOCLOSEPROCESS|SEE_MASK_FLAG_NO_UI)
BinaryPoke4(hBBSEI,08,0)
BinaryPoke4(hBBSEI,12,pBBlpVerb)
BinaryPoke4(hBBSEI,16,pBBlpFile)
;BinaryPoke4(hBBSEI,20,0)
;BinaryPoke4(hBBSEI,24,0)
BinaryPoke4(hBBSEI,28,SW_SHOWNORMAL)
;BinaryPoke4(hBBSEI,32,0)
;BinaryPoke4(hBBSEI,36,0)
;BinaryPoke4(hBBSEI,40,0)
;BinaryPoke4(hBBSEI,44,0)
;BinaryPoke4(hBBSEI,48,0)
;BinaryPoke4(hBBSEI,52,0)
;BinaryPoke4(hBBSEI,56,0)

shell32=StrCat(DirWindows(1),"shell32.dll")
iResult=DllCall(shell32,long:"ShellExecuteExA",lpbinary:hBBSEI)
If iResult<>0
   WAIT_TIMEOUT=258
   hHandle=BinaryPeek4(hBBSEI,56)
   kernel32=StrCat(DirWindows(1),"kernel32.dll")
   While WAIT_TIMEOUT==DllCall(kernel32,long:"WaitForSingleObject",long:hHandle,long:0)
      TimeDelay(1)
   EndWhile
EndIf

BinaryFree(hBBSEI)
BinaryFree(hBBlpFile)
BinaryFree(hBBlpVerb)

Return
;..........................................................................................................................................
;   typedef struct _SHELLEXECUTEINFO {
;       DWORD  cbSize;                          ;    cbSize        As Long
;       ULONG  fMask;                           ;    fMask         As Long
;       HWND  hwnd;                             ;    hwnd          As Long
;       LPCTSTR  lpVerb;                        ;    lpVerb        As String
;       LPCTSTR  lpFile;                        ;    lpFile        As String
;       LPCTSTR  lpParameters;                  ;    lpParameters  As String
;       LPCTSTR  lpDirectory;                   ;    lpDirectory   As String
;       int  nShow;                             ;    nShow         As Long
;       HINSTANCE  hInstApp;                    ;    hInstApp      As Long
;       LPVOID  lpIDList;                       ;    lpIDList      As Long     'Optional
;       LPCTSTR  lpClass;                       ;    lpClass       As String   'Optional
;       HKEY  hkeyClass;                        ;    hkeyClass     As Long     'Optional
;       DWORD  dwHotKey;                        ;    dwHotKey      As Long     'Optional
;       union {                                 ;    hIcon         As Long     'Optional
;           HANDLE  hIcon;                      ;
;           HANDLE  hMonitor;                   ;
;       } DUMMYUNIONNAME;                       ;
;       HANDLE  hProcess;                       ;    hProcess      As Long     'Optional
;   } SHELLEXECUTEINFO, *LPSHELLEXECUTEINFO;
;..........................................................................................................................................
;   ; SHELLEXECUTEINFO fMask-Konstanten
;   SEE_MASK_CLASSKEY       = 3    ; &H3    ; Struktur wird mit dem Handle des Registry - Schluessels fuer die Klasse gefuellt
;   SEE_MASK_CLASSNAME      = 1    ; &H1    ; Struktur wird mit dem Klassennamen oder GUID gefuellt der die Datei beschreibt
;   SEE_MASK_CONNECTNETDRV  = 128  ; &H80   ; Struktur verbindet den PC mit einem Netzlaufwerk falls noetig, lpFile muss der UNC-Pfadname in dem Netzwerk sein
;   SEE_MASK_DOENVSUBST     = 512  ; &H200  ; Struktur wird mit Umgebungsvariablen des Programms gefuellt, diese werden in lpDirectory oder lpFile gepackt
;   SEE_MASK_FLAG_DDEWAIT   = 256  ; &H100  ; die Funktion wartet, dass die DDE ihre Vorgaenge abgeschlossen hat und kehrt dann erst zurueck
;   SEE_MASK_FLAG_NO_UI     = 1024 ; &H400  ; die Funktion zeigt keine Fehler-Dialogboxen an
;   SEE_MASK_HOTKEY         = 32   ; &H20   ; dwHotkey wird gefuellt
;   SEE_MASK_ICON           = 16   ; &H10   ; hIcon wird gefuellt mit dem Icon-Handle des Standard-Icons der Anwendung
;   SEE_MASK_IDLIST         = 4    ; &H4    ; benutzt die lpIDLIST-Option um das Programm zu starten, das in ihr beschrieben ist
;   SEE_MASK_INVOKEIDLIST   = 12   ; &HC    ; benutzt die lpIDLIST-Option um das Programm zu starten, das in ihr beschrieben ist
;   SEE_MASK_NOCLOSEPROCESS = 64   ; &H40   ; fuellt die Struktur-Option hProcess  mit dem Process-Handle der gestarteten Anwendung
;..........................................................................................................................................
;   ; SHELLEXECUTEINFO nShow-Konstanten
;   SW_HIDE                 = 0    ; versteckt das Fenster
;   SW_MAXIMIZE             = 3    ; maximiert das Fenster
;   SW_MINIMIZE             = 6    ; minimiert das Fenster
;   SW_RESTORE              = 9    ; stellt das Fenster wieder her
;   SW_SHOW                 = 5    ; zeigt das Fenster an
;   SW_SHOWMAXIMIZED        = 3    ; zeigt das Fenster maximiert an
;   SW_SHOWMINIMIZED        = 2    ; zeigt das Fenster minimiert an
;   SW_SHOWMINNOACTIVE      = 7    ; zeigt das Fenster minimiert an, aber aktiviert es nicht
;   SW_SHOWNA               = 8    ; zeigt das Fenster an, aber aktiviert es nicht
;   SW_SHOWNOACTIVATE       = 4    ; zeigt das Fenster in der besten Groeße und Position an, aber aktiviert es nicht
;   SW_SHOWNORMAL           = 1    ; zeigt das Fenster normal an
;..........................................................................................................................................
;   ; SHELLEXECUTEINFO hInstApp Rueckgabe-Konstanten
;   SE_ERR_ACCESSDENIED     = 5    ; Zugriff verweigert
;   SE_ERR_ASSOCINCOMPLETE  = 27   ; Dateityp ist nicht ausreichend assoziiert
;   SE_ERR_DDEBUSY          = 30   ; DDE konnte nicht gestartet werden
;   SE_ERR_DDEFAIL          = 29   ; DDE ist gescheitert
;   SE_ERR_DDETIMEOUT       = 28   ; DDE-Zeitlimit wurde ereicht
;   SE_ERR_DLLNOTFOUND      = 32   ; eine benoetigte Dll wurde nicht gefunden
;   SE_ERR_FNF              = 2    ; Datei wurde nicht gefunden
;   SE_ERR_NOASSOC          = 31   ; Dateityp ist nicht assoziiert
;   SE_ERR_OOM              = 8    ; nicht genuegend Speicher verfuegbar
;   SE_ERR_PNF              = 3    ; Pfad wurde nicht gefunden
;   SE_ERR_SHARE            = 26   ; Datei konnte nicht geoeffnet werden, da sie bereits verwendet wird
;..........................................................................................................................................
;   ; SHELLEXECUTEINFO dwHotKey-Konstanten
;   HOTKEYF_ALT             = 4    ; &H4  ; benutzt ALT fuer den Hotkey
;   HOTKEYF_CONTROL         = 2    ; &H2  ; benutzt STRG fuer den Hotkey
;   HOTKEYF_EXT             = 8    ; &H8  ; benutzt den Extendend-Key fuer den Hotkey
;   HOTKEYF_SHIFT           = 1    ; &H1  ; benutzt Shift fuer den Hotkey
;..........................................................................................................................................
;   ; WaitForSingleObject dwMillisecond-Konstante
;   INFINITE                = 65535; &HFFFF ; unendlich warten
;..........................................................................................................................................
;   ; WaitForSingleObject Rueckgabe-Konstanten
;   WAIT_ABANDONED          = 128  ; &H80        ; Der Mutex, der in hHandle angegeben ist, wird nicht freigegeben, solange der Eltern-Thread zerstoert ist.
;                                                ; Der Mutex ist nun Bestandteil des aufrufenden Threads und ist nicht mehr im signalisierenden Status.
;   WAIT_FAILED             = -1   ; &HFFFFFFFF  ; Die Funktion ist gescheitert.
;   WAIT_OBJECT_0           = 0    ; &H0         ; Das Objekt. das in hHandle spezifiziert ist, ist in einem signalisierendem Status.
;   WAIT_TIMEOUT            = 258  ; &H102       ; Das Zeitlimit fuer eine Aenderung des Thread-Status ist abgelaufen.
;..........................................................................................................................................
;   Reference: VB API Helpline; vb@rchiv © 2000-2003 Dieter Otter
;
; Detlev Dalitz.20030129
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------


; --- test ---

sFilename = "notepad.exe"
iResult = udfDisplayPropertiesSheet (sFilename)

TimeDelay(2)

sFilename = StrCat(DirHome(),"WBOwl.bmp")
iResult = udfDisplayPropertiesSheet (sFilename)

TimeDelay(2)

sFilename = IntControl(1004,0,0,0,0)
iResult = udfDisplayPropertiesSheet (sFilename)

TimeDelay(2)

Message("Waiting ...","... press OK to quit.")
Exit
;------------------------------------------------------------------------------------------------------------------------------------------

Article ID:   W15750
File Created: 2003:05:13:11:29:56
Last Updated: 2003:05:13:11:29:56