13 Replies - 1965 Views - Last Post: 03 April 2012 - 09:31 AM Rate Topic: -----

#1 FoodGood  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 97
  • Joined: 08-July 09

[VBS] handling multiple files in context menu

Posted 17 March 2012 - 06:58 AM

Hello
I wrote a script that added an item to right-click context menu, and sent all selected folders as arguments
The problem is that the OS creates a new instance of the script on each selected folder.

For example: if I marked 3 folders, there will be 3 instances of the script, each has one argument with a folder's path, and I need 1 instance of the script with 3 arguments

How can I solve this?

P.S
I have no code to show you, because it is in work : )
I only have to complete this part

Thanks!

Is This A Good Question/Topic? 0
  • +

Replies To: [VBS] handling multiple files in context menu

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5439
  • View blog
  • Posts: 11,669
  • Joined: 02-June 10

Re: [VBS] handling multiple files in context menu

Posted 17 March 2012 - 10:37 AM

So you're saying "I won't show you what I'm doing, so you can help me. Just give me working code that fits my needs."

We don't do that here. We will help you with your code.
Was This Post Helpful? 0
  • +
  • -

#3 FoodGood  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 97
  • Joined: 08-July 09

Re: [VBS] handling multiple files in context menu

Posted 17 March 2012 - 09:55 PM

No man : /
You can see other threads I've opened
The mission is actually select folders-->right click-->choose custom item I added to the context menu-->show screen with the number of the selected folders and their size
My code (which again..is not on my computer at home and can't be moved to it because it's a different network) has all the components, except it's running multiple times instead of one..that's the only part I need : )
Was This Post Helpful? 0
  • +
  • -

#4 GunnerInc  Icon User is offline

  • "Hurry up and wait"
  • member icon




Reputation: 858
  • View blog
  • Posts: 2,277
  • Joined: 28-March 11

Re: [VBS] handling multiple files in context menu

Posted 17 March 2012 - 10:33 PM

Well, I guess we will have to wait until the next time your at work to post the script.

Imagine, the engine in your car is making a horrible noise; you can't drive it to the mechanic so you take a cab. You then tell the mechanic about the noise and ask him how can you/him/her solve this. IMPOSSIBLE!!!

We have to see the code in order to tell you what is wrong with it.
Was This Post Helpful? 0
  • +
  • -

#5 FoodGood  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 97
  • Joined: 08-July 09

Re: [VBS] handling multiple files in context menu

Posted 18 March 2012 - 11:31 AM

View PostGunnerInc, on 17 March 2012 - 10:33 PM, said:

Well, I guess we will have to wait until the next time your at work to post the script.

Imagine, the engine in your car is making a horrible noise; you can't drive it to the mechanic so you take a cab. You then tell the mechanic about the noise and ask him how can you/him/her solve this. IMPOSSIBLE!!!

We have to see the code in order to tell you what is wrong with it.


As I said..my work has a different network..it is not connected to the "regular" one
However I wrote a simple example at home
Lets say I want to mark folders with the mouse, right click on them, select my command from the context menu and a message with the number of the marked folders pop up

So this is my script:
WScript.Echo "Num Folders Selected: " & WScript.Arguments.Count



I added the right keys in the registry: HKEY_CLASSES_ROOT\Directory\shell\Folders Counter\command
The default value: wscript.exe "SomePath\vbsTest.vbs" "%1"

The result:

Posted Image
Instead of one popup with "3" in it

I don't know what should I do to accomplish this..
I read that %2 %3 etc won't help
Was This Post Helpful? 0
  • +
  • -

#6 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5439
  • View blog
  • Posts: 11,669
  • Joined: 02-June 10

Re: [VBS] handling multiple files in context menu

Posted 18 March 2012 - 11:35 AM

In generic term... Quit calling your MessageBox from within a loop.
Increment a counter, then call the MessageBox after the loop is complete.
Was This Post Helpful? 0
  • +
  • -

#7 FoodGood  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 97
  • Joined: 08-July 09

Re: [VBS] handling multiple files in context menu

Posted 18 March 2012 - 12:33 PM

View PosttlhIn`toq, on 18 March 2012 - 11:35 AM, said:

In generic term... Quit calling your MessageBox from within a loop.
Increment a counter, then call the MessageBox after the loop is complete.


It is not a loop
My code has only 1 line, which is the line I wrote earlier : )
It opens 3 message boxes because I marked 3 folders-->right click on them-->chose my command
It actually opens 3 instances of wscript.exe for each folder, and I want 1 instance with 3 parameters or maybe to ask if my script (which have to be another name in the task manager, instead of wscript.exe) is already running, and if it does so send the folder to it (the running one) instead of open new instance of the script : )

Thanks

This post has been edited by FoodGood: 18 March 2012 - 12:34 PM

Was This Post Helpful? 0
  • +
  • -

#8 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5439
  • View blog
  • Posts: 11,669
  • Joined: 02-June 10

Re: [VBS] handling multiple files in context menu

Posted 18 March 2012 - 12:50 PM

Quote

The problem is that the OS creates a new instance of the script on each selected folder.


Ok... That makes sense. Simplistic script with 3 instances in play. Each instance creates a MessageBox.

So there's no controller of any kind? No service running... no application in the background minimized to a task tray?

I think that's the direction you're going to need to go. You need some sort of parent controller that all these child script instances report to. Instead of each one creating a MessageBox they need to notify the controller (service?) that they're done. Then the controller can do whatever it needs to do: Write a log entry, open a MessageBox, open a tasktray notify balloon ...
Was This Post Helpful? 0
  • +
  • -

#9 GunnerInc  Icon User is offline

  • "Hurry up and wait"
  • member icon




Reputation: 858
  • View blog
  • Posts: 2,277
  • Joined: 28-March 11

Re: [VBS] handling multiple files in context menu

Posted 18 March 2012 - 02:13 PM

Your script does work correctly from cmd, passing it args it returns the correct number. Using from Explorer will be a lot more involved. Probably be easier to write an app that counts the params and pass it to the script.

Attached Image
Was This Post Helpful? 0
  • +
  • -

#10 FoodGood  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 97
  • Joined: 08-July 09

Re: [VBS] handling multiple files in context menu

Posted 18 March 2012 - 09:51 PM

View PosttlhIn`toq, on 18 March 2012 - 12:50 PM, said:

Quote

The problem is that the OS creates a new instance of the script on each selected folder.


Ok... That makes sense. Simplistic script with 3 instances in play. Each instance creates a MessageBox.

So there's no controller of any kind? No service running... no application in the background minimized to a task tray?

I think that's the direction you're going to need to go. You need some sort of parent controller that all these child script instances report to. Instead of each one creating a MessageBox they need to notify the controller (service?) that they're done. Then the controller can do whatever it needs to do: Write a log entry, open a MessageBox, open a tasktray notify balloon ...


As far as I know, wscript.exe is the running process in background
If I write a parent controller, the problem is how can I make it run only one..don't forget that the right-click menu item is the trigger

View PostGunnerInc, on 18 March 2012 - 02:13 PM, said:

Your script does work correctly from cmd, passing it args it returns the correct number. Using from Explorer will be a lot more involved. Probably be easier to write an app that counts the params and pass it to the script.


That's what I want to know..The explorer thing
I didn't find it anywhere
Was This Post Helpful? 0
  • +
  • -

#11 GunnerInc  Icon User is offline

  • "Hurry up and wait"
  • member icon




Reputation: 858
  • View blog
  • Posts: 2,277
  • Joined: 28-March 11

Re: [VBS] handling multiple files in context menu

Posted 19 March 2012 - 03:59 PM

Well, got it to work! Seems you have to put the script in your SendTo folder then select the files/folders then right click then select SendTo and select your script.

Attached image(s)

  • Attached Image

Was This Post Helpful? 0
  • +
  • -

#12 FoodGood  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 97
  • Joined: 08-July 09

Re: [VBS] handling multiple files in context menu

Posted 02 April 2012 - 10:58 PM

View PostGunnerInc, on 19 March 2012 - 03:59 PM, said:

Well, got it to work! Seems you have to put the script in your SendTo folder then select the files/folders then right click then select SendTo and select your script.


Hi
Sorry about the delay :rolleyes:
I have already knew this solution
This is not the one I'm looking for
I know there is a solution, but I can't find it..I think it is a registry solution :wacko:
Was This Post Helpful? 0
  • +
  • -

#13 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5439
  • View blog
  • Posts: 11,669
  • Joined: 02-June 10

Re: [VBS] handling multiple files in context menu

Posted 03 April 2012 - 07:59 AM

The man shows you a working solution for your issue, and now you want to be picky about it not being the right solution to the issue?

We aren't mind readers. We don't know which of 15 ways you already know but found unacceptable.

<unsubscribing from this thread>
Was This Post Helpful? 0
  • +
  • -

#14 FoodGood  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 97
  • Joined: 08-July 09

Re: [VBS] handling multiple files in context menu

Posted 03 April 2012 - 09:31 AM

View PosttlhIn`toq, on 03 April 2012 - 07:59 AM, said:

The man shows you a working solution for your issue, and now you want to be picky about it not being the right solution to the issue?

We aren't mind readers. We don't know which of 15 ways you already know but found unacceptable.

<unsubscribing from this thread>


Don't blame the messenger :sweatdrop:
The reason I'm still asking for a solution, is because the "sent to" solution is not fitting the problem..It is a work-around :smartass:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1