Create a self-executing folder?

TechLarry

RIP [H] Brother - June 1, 2022
Joined
Aug 9, 2005
Messages
30,483
I want to create a folder on the desktop that executes any program dropped into it automatically.

I know it can be done with WMI scripting but WMI scripting is not my strong suite :)

Anyone know of a clean utility that can do this easily?
 

defaultluser

[H]F Junkie
Joined
Jan 14, 2006
Messages
14,399
Maybe a batch script might be more manageable if you're not going with WMI

https://stackoverflow.com/questions/51867874/run-command-with-drag-and-drop-onto-batch-file

Code:
@echo off
start "%~1"

-or-

Code:
@echo off

for %%a in (%*) do start [%%a]

WMI reference just in case https://devblogs.microsoft.com/scri...-script-any-time-a-file-is-added-to-a-folder/


Yeah, if you just want to execute something dragged into a folder, you're EITHER going to have to delete it afterwards, or you're going to have to keep track of everything already there.

But you can do this using Windows Task Scheduler (just set it for 1 second activation delay, and then search the folder for a list for files.)


But dragging it onto a Batch file simplifies your task immensely
 

TechLarry

RIP [H] Brother - June 1, 2022
Joined
Aug 9, 2005
Messages
30,483
Maybe a batch script might be more manageable if you're not going with WMI

https://stackoverflow.com/questions/51867874/run-command-with-drag-and-drop-onto-batch-file

Code:
@echo off
start "%~1"

-or-

Code:
@echo off

for %%a in (%*) do start [%%a]

WMI reference just in case https://devblogs.microsoft.com/scri...-script-any-time-a-file-is-added-to-a-folder/
Those are great, but I don's know how to implement scripts. After 30 years you would think I would, but wmi scripting is just one on those windows rabbit holes i've never had time to jump in to.

Do you just give it a certain file extension and double click it ?

How do you kill it?
 

TechLarry

RIP [H] Brother - June 1, 2022
Joined
Aug 9, 2005
Messages
30,483
Yeah, if you just want to execute something dragged into a folder, you're EITHER going to have to delete it afterwards, or you're going to have to keep track of everything already there.

But you can do this using Windows Task Scheduler (just set it for 1 second activation delay, and then search the folder for a list for files.)


But dragging it onto a Batch file simplifies your task immensely
Cant drag it onto anything. The file is presented in a file save dialog.

Here's the scoop. We use Bomgar for remote support. We use SAML authentication. Here is the login process:

1. For every ticket, launch Bomgar,
2. Click Login.
3. The system creates a custom Host .EXE and pops up a Save Dialog for it.
4. You save the file.
5. You go to explorer, find the file, and execute.
6. You are now logged in.

I have to go through this process 20-30 times a day.

I want to eliminate step 5. It annoys the shit out of me because it is stupid and inefficient.

OH... And because each Host Client is only good for that one login session, cleanup is easy. It self deletes after execution.

I will look into Task Scheduler.
 

Okatis

Limp Gawd
Joined
Jan 16, 2014
Messages
206
Here's the scoop...
Is there only ever one of these custom EXEs in the directory you save it to at a time, given they self-delete after execution?

Also is the naming of the EXE dynamic/changing each time? And if it does change whether there's always part of the filename that stays the same.

As this could be streamlined a bit.
 
Last edited:

defaultluser

[H]F Junkie
Joined
Jan 14, 2006
Messages
14,399
if you just want to select the newest files in a location try forfiles ,,,but I'm not sure how you can execute every file on the list?
 

Eulogy

2[H]4U
Joined
Nov 9, 2005
Messages
2,900

TechLarry

RIP [H] Brother - June 1, 2022
Joined
Aug 9, 2005
Messages
30,483
Is there only ever one of these custom EXEs in the directory you save it to at a time, given they self-delete after execution?

Also is the naming of the EXE dynamic/changing each time? And if it does change whether there's always part of the filename that stays the same.

As this could be streamlined a bit.
Same name every time and it indeed self delete's every time.
 

TechLarry

RIP [H] Brother - June 1, 2022
Joined
Aug 9, 2005
Messages
30,483
Ok, now that you've actually explained what you REALLY want to do...
Check out the Bomgar API docs, especially here:
https://www.beyondtrust.com/docs/remote-support/how-to/integrations/api/client-script/index.htm

You mentioned having been doing this for 30 years, so I'm guessing you're at the point where you're mostly just phoning it in. But spending a bit of time reading through that, you could automate the entire thing out pretty simply, from what I can tell.
You must understand, I am just the guy in the trenches clearing tickets. I do not and never will have any access, control of, or input into the actual Bomgar appliance or it's configuration.
 

Okatis

Limp Gawd
Joined
Jan 16, 2014
Messages
206
Same name every time and it indeed self delete's every time.
You have few straightforward options I can think of, starting with the simplest first.

1. Browser launch method. After saving the EXE in the browser launch directly from the Downloads tab/page/icon of the browser. In Chrome recent downloads appear in a strip at the bottom of the browser window that can be clicked to open, while in Firefox they can be set to show in a downloads icon in the browser toolbar. In Vivaldi browser there's a sidebar panel showing downloaded files that can be launched by double-clicking them.

Advantage: easy to launch in most browsers without navigating to file manually, no extra files/scripts necessary.​
Disadvantage: not automatic.​

2. Shortcut launch method. After the EXE has been created create a Windows shortcut to the EXE, then pin the shortcut to the start menu or place it on the desktop for convenience. Launch the EXE via the shortcut after each new EXE has been saved.

Assuming the EXE is always saved to the same location each time the shortcut will find it since the EXE always has the same filename and location.​
Advantage: straightforward.​
Disadvantage: not automatic.​

3. Always running method. Using something such as a custom batch script that is left open in the background to periodically check for the presence of the EXE in a directory and run it (eg: every few seconds).

Advantage: detects and launches EXE quasi-automatically.​
Disadvantage: if on a work system there may be some restriction from opening batch scripts, not fully automatic detection since it relies on periodic checking.​



Attached is a simple batch script I made for the last method. By default it checks the same directory the script is located in for a file named 'Example.exe' every 10 seconds. These settings can be changed by editing the script in a text editor like Notepad, which is explained in the script's comments (prefixed by :: ).

Expects no special characters like ! % & in the directory path used to save the EXE to/place the script within. So eg: D:\Example path!!\ shouldn't be used but apart from that it should be fine.

29Moo21.gif
 

Attachments

  • LoginLauncherChecker.zip
    756 bytes · Views: 0

TechLarry

RIP [H] Brother - June 1, 2022
Joined
Aug 9, 2005
Messages
30,483
Good stuff man. Thanks !

I dont remember why, but #1 will not work. It might be a CMMC thing which has become the bane of my frickin' existance.

#2 is sneaky. I like it :)

#3 is hot. I think that is where I;ll trry first, mainly because I''ve nevwe used a loop[ing batch file before and I want to see it in action.

Thanks :)
 

cybereality

[H]F Junkie
Joined
Mar 22, 2008
Messages
8,790
I don't understand. Are the clients/customers using computers you control or have access to?

Because if you don't have access, you can't run a script to auto-launch an exe (since the script itself would be executable, you could just as easily launch the actual exe).
 

Eulogy

2[H]4U
Joined
Nov 9, 2005
Messages
2,900
I don't understand. Are the clients/customers using computers you control or have access to?

Because if you don't have access, you can't run a script to auto-launch an exe (since the script itself would be executable, you could just as easily launch the actual exe).
He's using Bomgar which is a remote assistance software, which runs on his local machine.
 
Top