DOpus on U3 -> Making portable apps accessibles from toolbar

Alright, I tried without U3, and I guess i'll keep it that way, it seems easier to handle and way more open to anything...

I tried to reply in the topic you gave me the link, but I can't.

So here is what I found:

  • works fine with the 3 different syntaxes in the command line (as DOpus app isn't temporarily copied to system before launching on U3)

  • Commands Icons only accepts one syntax (otherwise the icon isn't displayed):

/home\..\UTILS\HANDY.EXE

Hope this can help, and maybe a little improvement to add to the todo list for DOpus future releases...

Using the /home alias for icon paths doesn't seem very reliable to me (I'm not sure it was envisioned that people would use it, although it's obviously useful).

For me aliases in icon paths do work but only if they point to DLL files. ICO, PNG and EXE files don't work. Is that the same for you?

If it's the same for you I'll file it as a feature request to make it work. Otherwise I'll see if I can work out why it isn't working for me and update the FAQ.

I know it's not the best thing to use, but I don't really want to make a set of icons for these applications. I'm kind of lazy about some issues like that when I think there could be another way to do the same thing (with less efforts?) :wink:

I gave a try to what you told, but it doesn't work for me.
I tried to use the /home alias written this way in icon paths : {alias|home} & {alias|home|}, but both still doesn't work on my comp, even for DLL files.

The only way I can reach the icons is to use this syntax:
/home\ ....
It is not depending on the file type, this works so far with all the files I pointed to, DLL, ICO & EXE. I only didn't try to point PNG file type.

Well, with the searches I made lately on a way to be able to get the drive letter of a usb key through its volume name, I finally found a batch which seems to work perfectly, but it would need to be incorporated into the button directly to work fine on all the computers using win XP...

Here's the link to the page i found the batch, I'll see tomorrow if I can make it work for toolbar buttons correctly, and let know if this works correctly....
http://www.technologyquestions.com/technology/windows-xp/65318-batch-file-convert-volume-name-drive-letter.html

But of course, I don't post the code here as i'm not the writer of this batch

I used part of the script from my previous post to be able to determine the drive letter of my USB key, but still I do encounter some problems.

I used the echo function in my user command to be able to see if the %FLASHDRIVE% is set correctly, and it is.

The problem is when I use %FLASHDRIVE% to launch a command, it keeps telling me the path is not found.

@externalonly 

...

Set FLASHDRIVE=%%I:

Echo My Flashdrive is on drive %FLASHDRIVE%

%FLASHDRIVE%\PortableApps\Outils\EXECUTABLE.exe

I don't understand why it isn't working as %FLASHDRIVE% is correctly defined. Do you have any idea about this?

If you're trying to run that batch file you found by pasting the code directly into an Opus button, that may be why you're having problems. Certain complex batch operations need to be run directly from a batch file for some reason. The batch file you referenced works fine on my machine, I can use it to launch an application on my keyring flash drive just fine.

There are other batch file solutions you can use as well, such as the one following my message here. But all of them that I've tested must be run from an external batch file, and not with the code posted into an Opus button (even when it's set to MS-DOS Batch Function).

[code]@echo off
set VOLNAME=keyring

for /F %%a in ('mountvol /? ^| find ":"') do call :Sub %%a
goto :eof

:Sub
set X=%1
vol %X:~0,-1% 2>NUL|find /i "%VOLNAME%" 1>NUL && echo %VOLNAME% is on drive %X% && pause
goto:EOF[/code]

Have a look in your /temp directory. Opus creates batch files in there before running them, for MS-DOS type buttons. If you sort by date and find the latest temp batch files then you can see exactly what's being run and it'll probably make it obvious what the difference is.

It could be that you need to escape or double-up the % symbols in some places, for example, so that the variables are resolved at the right time.

(BTW, Opus automatically cleans up those temp files, don't worry.)

Leo I just inserted a pause into the button code so my MS-DOS Batch function type command is:

[code]@echo off
pause
set VOLNAME=keyring

for /F %%a in ('mountvol /? ^| find ":"') do call :Sub %%a
goto :eof

:Sub
set X=%1
vol %X:~0,-1% 2>NUL|find /i "%VOLNAME%" 1>NUL && echo %VOLNAME% is on drive %X% && pause
goto:EOF[/code]

But when I look at the temp batch file Opus creates while that pause is in effect, this is all there is:

@echo off chcp 1252 > nul C: cd "\TEMP" pause

Even if I delete everything after the

set VOLNAME=keyring

line the above is all that's in the temp batch file.

John: Try adding @externalonly to the top of the button.

Without that I think your set lines are invoking the Opus set command, not the intended MS-DOS set command.

(Looks like that was already in GoinPostal's button so it isn't that which was causing the original problem. My hunch is if you look at the batch files the % chars will be wrong.)

That did solve that problem Leo, thanks for that (and I should have known that myself!) :blush:

Thanks for the new batch John, it could be nicer than the one I have since it doesn't use temporary files.
In fact, I didn't used the code as it is, I changed some little things to be more the way I need it, but this doesn't really matters.
Also, I didn't used this code directly into a button, but as a user command, so I can call the script in any button I want without pasting all the code.

In fact, I don't have any problem with the script itself, as it works both as a batch or directly into DOpus, but to let you know what the purpose is, I can't afford to run this batch as a separate file because it would defeat the whole purpose of it. To explain some more, I would like to be able to have these toolbar buttons working both for my DOpus install on USB key, but also working on my home computer with the normal DOpus install when the USB key is inserted; that's also why I can't use the /home alias for that as it wouldn't work to find the path of the usb key when running from my home computer DOpus.

Alright, so leo, you guessed right!
The problem I have is that when trying to launch the command, the var is written this way: %%FLASHDRIVE%%.

I tried to escape the % chars with , but it still doesn't work.

I thought it was because I did that in a path, so I tried to use a @set command to define the volume name and escape the characters there, but nothing changes.

I may be a burden on that one, but I really don't see what to do to remove those double %....

PS: a little question on the @nofilenamequoting.... part of the problem was also that DOpus inserted quotes for the command launch, but the ending quote was not at the right place (I used a dlgchoose to be able to put various options), and the ending quote is put at the end of the options. I resolved this problem by putting the quotes myself on the command, but i also tried to use that @nofilenamequoting modifier, but it didn't changed anything. Is that the modifier only works for arguments and not the command itself?

Looking at your batch file from earlier:

[code]@externalonly

...

Set FLASHDRIVE=%%I:

Echo My Flashdrive is on drive %FLASHDRIVE%

%FLASHDRIVE%\PortableApps\Outils\EXECUTABLE.exe[/code]

What's being run is this:

%%I\PortableApps\Outils\EXECUTABLE.exe

But that makes sense because you set FLASHDRIVE to "%%I:" at the start.

The "%%I" stuff in the original batch file only makes sense if it's used in the context of the For command, as in the original:

For /F " tokens=3 " %%I in (VOLLIST.TXT) do SET FLASHDRIVE=%%I:

Inside the For command %%I is a variable called 'I' but outside of it it turns into a literal string, "%%I".

(The DOS batch language, and the For command and %-escaping in particular, are quite confusing IMO.)

BTW, the original script uses DiskPart.exe to get a list of disk labels. That will cause problems on systems which use UAC, and for standard users, since DiskPart.exe requires admin rights. When I run the batch file it triggers a UAC prompt.

I'll see if I can come up with a VBScript which does what you want. The info should be available via the WMI objects... Will reply in a bit.

I wrote a VBScript you can use to do this:

pretentiousname.com/miscsoft ... chViaLabel

LaunchViaLabel.vbs "NameOfYourDrive" __DRIVE__\PortableApps\Outils\Executable.exe

Thanks leo!

The script works fine.

I just have another question. Is it possible to put that script as a user command using the modifier @script vbscript?

I tried that but on the console, it keeps telling me that WScript isn't defined for that line:
Set Args = WScript.Arguments

I watched on the forum to see if I could get some informations, but I didn't found anything yet about this particular problem.

My last question is just to try understand a little more how does vbscript can be implemented in DOpus.

I can easily find a workaround if I need to use this vbscript as an external file.
I can put the script in the DOpus install folder for both my home computer and USB key and call it via /home alias for the path!

I tried to use this vbs script for several commands now with the file located in the DOpus folder.

But finally, I reach its limitations :wink:.

The Run method in VBScript can't handle command line redirection to a file.

I didn't found a workaround yet, but i'm searching some to see if there's a way to allow this!

You could do it by abusing the rename scripting functionality. Or just call it as an external batch file.

If you want DOS features like redirection then it's probably easiest to run a batch file from the script. Perhaps there is a way to do it using just VBScript but I don't know.

For what I saw yet, changing the last line of your code does the trick:

Shell.Run "%ComSpec% /c" & CmdLine & " > " & OutputFile, 1, WaitForCommand

OutputFile would be a parameter that the script gets....
But the main problem is here. When using the WScript.Arguments method (is it a method? i'm not sure though), the redirection parameter is ignored.

So, I guess the better thing to do would be to use another special character that VBScript won't discard as argument to indicate the script that the redirected filename is coming right after.

I'll try to make something like this soon (being able to handle both normal command launch & command with redirection), and post the code here!

I knew I had to go through VBScript again sooner or later :wink:, even if it's not what I prefer.
I'm not that much into scripting :wink:, but way more into programming using good old C & ASM when needed :smiley:

Anyways, thanks a lot again for your quick help!

Using cmd.exe, good idea!

Yeah, you'll need to pass something other than ">" as an argument to the VBScript, then have it replace the special thing with ">" when sending the line to cmd.exe.

Here we go, here's the script updated!

It feels good :slight_smile: I'll finally be able to put all my little own & other command line tools to help about software development on my USB key being able to use also redirection!!!!

DOpus rules :wink: This will save me a lot of time about these little commands I use almost every day!

Thanks again for all the great help, I could have searched for a while otherwise!
LaunchViaLabel(v2).zip (1.7 KB)