this-is-me Posted August 2, 2004 Share Posted August 2, 2004 (edited) Since so many people have trouble "running" files, I thought I would make a fake shellexecute to allow direct "running" of files. You may also select the verb to execute on the file. For those of you who don't know, a verb is like open, edit, print, etc.func shellexecute($file, $verb) $ext = StringTrimLeft($file, StringInStr($file, ".", 0, -1)) $fltp = RegRead("HKEY_CLASSES_ROOT\." & $ext, "") if @error Then $fltp = $ext & "file" $defverb = RegRead("HKEY_CLASSES_ROOT\" & $fltp & "\shell", "") if $defverb = "" Then $defverb = "Open" if $verb = "" Then $cmd = RegRead("HKEY_CLASSES_ROOT\" & $fltp & "\shell\" & $defverb & "\command", "") Else $cmd = RegRead("HKEY_CLASSES_ROOT\" & $fltp & "\shell\" & $verb & "\command", "") EndIf if @error Then $cmd = RegEnumKey("HKEY_CLASSES_ROOT\" & $fltp & "\shell", 1) if @error Then Return 2 EndIf $cmd = StringReplace($cmd, "%l", FileGetLongName($file)) $cmd = StringReplace($cmd, "%1", $file) $cmd = StringReplace($cmd, "%*", "") for $i = 2 to 9 $cmd = StringReplace($cmd, "%" & $i, "") Next ;Why do I have to do this instead of expandenvstrings? $env = StringInStr($cmd, "%", 0, 1) if not @error Then for $i = 1 to 5 Step 2 if not StringInStr($cmd, "%", 0, $i) Then ExitLoop $envx = StringMid($cmd, StringInStr($cmd, "%", 0, $i) + 1, StringInStr($cmd, "%", 0, $i + 1) - 2) $cmd = StringReplace($cmd, "%" & $envx & "%", EnvGet($envx)) Next EndIf Run($cmd) endfunc Example: shellexecute("C:\boot.ini", "") If run with the second parameter, It performs a separate operation on the file. shellexecute(@ScriptFullPath, "Edit") @jon, What happened to the tabs in code blocks? It shows fine in edit boxes, but not in the posted page. Edited August 3, 2004 by this-is-me Who else would I be? Link to comment Share on other sites More sharing options...
ezzetabi Posted August 2, 2004 Share Posted August 2, 2004 I am afraid that it may have problems working. The HKCR is not very sure with all this new programs that uses the {uncomprensible hashes}. Am I wrong? Link to comment Share on other sites More sharing options...
this-is-me Posted August 2, 2004 Author Share Posted August 2, 2004 I think you mean the clsid like {00000001-4FEF-40D3-B3FA-E0531B897F98}. If you do, then no. Those are not referencing file associations. The only thing my script does is find the associated program for a file and launch it. Who else would I be? Link to comment Share on other sites More sharing options...
ezzetabi Posted August 3, 2004 Share Posted August 3, 2004 I fugured it out. Thanks. Very nice the idea of looking for the $fltp value in that way. Great Link to comment Share on other sites More sharing options...
trids Posted August 3, 2004 Share Posted August 3, 2004 @jon, What happened to the tabs in code blocks? It shows fine in exit boxes, but not in the posted page.It seems that a block ignores tabs, but honours spaces: so you can use 4 spaces for each indentation level Link to comment Share on other sites More sharing options...
this-is-me Posted August 3, 2004 Author Share Posted August 3, 2004 Yea, but that means that I would need to re-tidy my script before posting each time. I wonder if there is a setting in the board to fix... Who else would I be? Link to comment Share on other sites More sharing options...
Administrators Jon Posted August 3, 2004 Administrators Share Posted August 3, 2004 Yea, but that means that I would need to re-tidy my script before posting each time. I wonder if there is a setting in the board to fix... Whenever I've used tabs in the past it's appeared like that and I've had to use spaces to format properly. Sure its a recent thing? Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
this-is-me Posted August 3, 2004 Author Share Posted August 3, 2004 Just before the new blue ui it worked fine. Who else would I be? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now