PDA

View Full Version : RunSilent plugin bug ?


qwerty
08-11-2008, 03:16 PM
i've pm'd Worm on this one as it's his plugin, but thought i'd ask here if anyone else has encountered this.....


i'm using Worms plugin to run a commandline tool that has 3 sets of parameters, i built the associated script i use with this tool in a seperate test application, then transfered it into my main project... so i know it works.

when i transferred it to the main project, it was in the OnClick event for one of the buttons (same as the test app).... and it failed spectacularly :wow

so, i started going through what i did wrong transferring it in, did i change something, had i messed up and placed it in the middle of another block of code by mistake.... nope, i could see nothing wrong.

so, out of desperation, and in the hope of trying to work out what was clashing or stopping it from working, i moved the block of code in question to the OnStartup section.... low and behold it worked like a charm, ok... baffled i proceeded to turn off things like timers, disable plugins etc etc in the hope of finding the problem..... no good

Then.... by mistake i closed the main project without saving it, no problem, as all i was playing with was this one block of code...

so i placed it back in the OnStartup section, but... this time i placed it at the end of the script, and once again it failed

hhhmmm ... it turned out that the Folder.Create function seems to kill the RunSilent plugin...

place the RunSilent.Exec call before this section of my code and it works, place it directly after it and it fails

--- Generate a random number --
nRandom = Math.Random(1000000000);

--- Create a temp folder in the user's Temp directory for decrypted files --
Folder.Create(_TempFolder.. "\\"..nRandom);

i disabled the Math.Random line and gave the nRandom variable a set value, and the RunSilent script still failed, disable the Folder.Create line and the RunSilent script works perfectly :huh

i've also tested this by taking Worm's basic example apz and adding

Folder.Create(_TempFolder.. "\\Blah");

in front of his code, and sure enough it fails :(



anyone seen this before ?

qwerty
08-11-2008, 05:18 PM
ahhhh ha... i found a solution, messy as **** but it works.


The problem is related to working directory, basically if the Folder.Create function is used, then the working directory for RunSilent.Exec seems to get messed up.

For example, one of the command line parameters i'm using is " > text.dat" the command line tool i am using writes it's data to this file, what i noticed is that, that file is actually getting created, in the same location as the last folder created, even though the command line tool is not being activated :eek: ..... so, to work around the issue, i can create a folder in the directory that contains the command line tool, thats easy enough :)... but, RunSilent still fails to run the actual command line tool... until, i remove the file path for the tool :wow

so, to work around the problem, i need to do this whenever i create a folder, using my earlier example i would do this....


nRandom = Math.Random(1000000000);

Folder.Create(_TempFolder.. "\\"..nRandom); -- create random named folder in Temp
Folder.Create(_SourceFolder.. "\\AutoPlay\\Docs\\Utils\\test"); -- create a test folder to restore working directory association

RunSilent.Exec("MY.exe ", " > ADS.dat") -- note, no file path


because the last path used for Folder.Create is the location of MY.exe there is no longer a need to append it to the front of the file name !

This works a treat, but... you need to remember to delete the "test" folder after each use, because if AMS is unable to create the folder (because it exists) then the working folder association is not set to the folder with my.exe in it


like i said, very messy... but will suffice untill a better solution is available or until Worm has time to look at the plugin... as it's an excellent little tool

of course, you can simply delete and create the foldder each time you plan to use RunSilent as this is probably easier to remember to do :p

qwerty
08-12-2008, 01:54 PM
ok, Worm Pm'd me..... and like the example of how to fix issues suggests, he wasnt sure how exactly the Folder.Create function was "breaking" the RunSilent Plugin, unless AMS itself was getting confused on the working folder.

He offered a very simple solution though, which i had over looked

the Folder.SetCurrent function !!.... set the working folder to the location of the exe to be run, and then as per my example above, dont use any file path info before the exe, and it works great :)

Thanks Worm

(hopefully if anyone else hits this issue they will now find the info needed when they search :) )

Worm
08-12-2008, 02:10 PM
No problem qwerty... glad to help. More glad that it worked than anything :)

qwerty
08-12-2008, 02:31 PM
yeah, it's always confusing when something either stops working or doesnt work right from the get go at all, and there seems to be no logical explanation.... this one had me going round in circles like a dog with a fixation on it's own tail ! :lol

appreciate the help :yes

RizlaUK
08-12-2008, 03:22 PM
well thats handy to know for future reference, nice catch :yes

SiNisTer
08-18-2008, 01:15 AM
the Folder.SetCurrent function !!.... set the working folder to the location of the exe to be run, and then as per my example above, dont use any file path info before the exe, and it works great :)


You could also set the working folder in The File.Run action. I had the same problem as you when I had to send commandline parameters to Daemon Tools a while back. Drove me nuts before I eventually figured it out.

I also noticed something else that works instead of setting a value for working folder in the File.Run action or using Folder.SetCurrent action. You should get the path to the file using File.GetShortName and enter that path in the appropriate filed. Works equally well.

Cheers

qwerty
08-18-2008, 02:21 AM
yeah, i see where your coming from with the working folder section on File.Run, but with RunSilent, is there a working folder parameter like that ?

i'm using worms solution at the moment and it's not giving me any trouble, but am always interested to learn new techniques

(i couldnt get my command line tool to run using File.Run, probably a case of my inability to get the scripting exactly right, whereas with RunSilent, except this quirk of working folder association it was nice and simple :) )

Protocol
10-17-2008, 10:50 AM
I had the exact same issue. I created some tests and this happens with only two lines of code. It's looking more and more like a OnStartUp issue, because (like you guys), I've used this so many times before under different locations without a hitch. After playing with it a bit, this works the best: Folder.SetCurrent(_SourceFolder); Just place this right after performing your Folder.Create function.

Here's the post to my prior testing: http://www.indigorose.com/forums/showthread.php?p=129228#post129228

Thanks for finding a temporary solution to this!