Sign in to follow this  
Followers 0
sgebbie

@ScriptFullPath help

5 posts in this topic

I've read quite a bit on here and haven't quite figured out how this command works exactly. I'm pretty new to all this stuff so I may be missing something pretty easy or straightforward. I'm working on a resume script after it executes a reboot. I know I need to add a REG entry before the reboot. I guess I need some help with explaining how this command works and possibly a couple other commands. I'll just start with this one since I'm not getting it.

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RUN", "script.exe", "REG_SZ", @ScriptFullPath & " " & $step)

In the help file it says @ScriptFullPath - Equivalent to @ScriptDir & "\" & @ScriptName

So where is this macro actually getting the path from? Say my script's path is located at \\server\test\script.exe

How is @ScriptFullPath able to get that directory to launch?

Here is the thread I've been looking at trying to figure this out and a few other commands I haven't gotten too far into yet.

http://www.autoitscript.com/forum/index.php?showtopic=26523&st=0&p=187218&#entry187218

If I can figure this part out I'll be working on the Case $param1 = "step1" "step2" parts of the examples to get my script to pick up at the point I want it to resume. I'm pretty good at figuring out a lot of this stuff but some of it i'm afraid I might need broken down a bit further into dummy terms ;) I need help turning the light on :evil:

Any help on this would be greatly appreciated.

Share this post


Link to post
Share on other sites



The @ScriptDir, @ScriptName, and @ScriptFullPath macros get their information from the Windows environment the script is running in. That information is available to all processes running in a Windows environment. The exact method used by the AutoIt interpreter would be implemented in the C (or C++) source code. Do you really need to go that far down the rabbit hole just to use it?

Just accept that the Windows environment includes every process being able to determine the where it was launched from at run time. The AutoIt interpreter makes that information available to your script through those macros.

;)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

The @ScriptDir, @ScriptName, and @ScriptFullPath macros get their information from the Windows environment the script is running in. That information is available to all processes running in a Windows environment. The exact method used by the AutoIt interpreter would be implemented in the C (or C++) source code. Do you really need to go that far down the rabbit hole just to use it?

Just accept that the Windows environment includes every process being able to determine the where it was launched from at run time. The AutoIt interpreter makes that information available to your script through those macros.

;)

That's plenty enough information for me I think. I don't think I'm looking at this quite as in depth as you are thinking I might be :evil: I'm real new to this and have only made a couple basic scripts. I was curious how it's getting the location of the script for this reason for example.

Say I create scriptA and compile it to exe. I push said exe from Configuration manager to a group of PCs so that I can have it launch at a ctrl+alt+del prompt. Script does its thing and adds a few reg entries and then reboots. One of those reg entries would be to call a new script in the autorun section of the registry.

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RUN", "scriptb.exe", "REG_SZ", @ScriptFullPath & " " & $step)

I was curious where it was going to be puling a default path from since scriptb wouldn't be running from the same location that scripta was in? Is this making any sense I hope? Any workaround suggestions if this will not work? If it just works and that's that, I'm good with that. I don't need to know the specifics if it just works so I can leave it alone if that's the case. I am worried that part is going to bomb when i get done working out the bugs of the other stuff since it didn't have a normal default path to start from.

Share this post


Link to post
Share on other sites

The term "at run-time" means the conditions that are present when the program (or script) is run, not when it is compiled or copied somewhere. So @ScriptFullPath being evaluated at run time means it will always reflect where the script is currently being run from.

If two copies of the same script are at "\\MyServer\MyShare\MyScripts\ScriptA.exe" and "C:\Program Files\MyScripts\ScriptA.exe", whichever one you run will get the appropriate different values from @ScriptFullPath. In addition, if you just change the name of the file to "MyScriptB.exe" without recompiling it, that will still be reflected in @ScriptName and @ScriptFullPath when it's run.

;)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

The term "at run-time" means the conditions that are present when the program (or script) is run, not when it is compiled or copied somewhere. So @ScriptFullPath being evaluated at run time means it will always reflect where the script is currently being run from.

If two copies of the same script are at "\\MyServer\MyShare\MyScripts\ScriptA.exe" and "C:\Program Files\MyScripts\ScriptA.exe", whichever one you run will get the appropriate different values from @ScriptFullPath. In addition, if you just change the name of the file to "MyScriptB.exe" without recompiling it, that will still be reflected in @ScriptName and @ScriptFullPath when it's run.

;)

Thanks for breaking all that down I appreciate it. I should be good now at least with that part.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0