Sign in to follow this  
Followers 0
wolflake

Identify self

7 posts in this topic

Hi,

I'd like to write a program that can be renamed but when it's run be able to know what it's new name is.

example:

a.exe is run and a message box opens and says my name is a

a.exe is renamed to b.exe

b.exe is run and a message box opens and says my name is b

Thanks in advance for your help.

-Rick

Share this post


Link to post
Share on other sites

@ScriptName is just what you need.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

Perhaps it's just my suspicious nature but I see some potential for nasties in this type of request.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

@ScriptName is just what you need.

Or rather, if he just wants to have the file name without the extension

$ext = StringRight(@ScriptName, 4)
$name = StringReplace(@ScriptName, $ext, "")
MsgBox(64, "Hello World!", "My name is " & $name & ", what's yours?")

Perhaps it's just my suspicious nature but I see some potential for nasties in this type of request.

Heh, I could see several different uses for it, I implemented something similar in one of my scripts to name it's Ini file after the script in case it gets renamed. Edited by zeffy

Share this post


Link to post
Share on other sites

Or rather, if he just wants to have the file name without the extension

$ext = StringRight(@ScriptName, 4)
$name = StringReplace(@ScriptName, $ext, "")
MsgBox(64, "Hello World!", "My name is " & $name & ", what's yours?")

Heh, I could see several different uses for it, I implemented something similar in one of my scripts to name it's Ini file after the script in case it gets renamed.

Yes that's exactly what I want it for. This program will have an ini file to go with it and it could be used for different things so it will be renamed for the different uses and I want it to look for it's complimentary ini.

Thank you again for your help.

Share this post


Link to post
Share on other sites

Reminds me of the time I made a "shortcut" script. It's basically a compiled AutoIt script which uses an ini file to set the program path and working folder used in a Run function. The plus side of using it is that I can use relative paths for the settings and I didn't have to resort to using a batch script and have to see an annoying console window.

Share this post


Link to post
Share on other sites

Reminds me of the time I made a "shortcut" script. It's basically a compiled AutoIt script which uses an ini file to set the program path and working folder used in a Run function. The plus side of using it is that I can use relative paths for the settings and I didn't have to resort to using a batch script and have to see an annoying console window.

My script is also a shortcut script. I use xplorer2 which has a command line. One of the machines I use it on I can't set paths to the original file and I would like to pass parameters which I can't do with regular shortcuts (well you can with the start in but it's always the same parameter). So I'm setting up an ini with the program you call on the first line. From there it passes the paramater to the program. Also you can have a second line with a command and parameter substitution. ie.

C:\autoit.exe

msgbox(0,"%1","%2")

where %1 and %2 are replaced by parameters typed in the command line (like in a batch file).

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