Jump to content
Sign in to follow this  
sagdude

update/prepend the path variable

Recommended Posts

sagdude

Hi

How do I update/prepend the path variable using AutoIt?

I have a program.exe file which I want to put at the beginning of the path (I want this program to be seen before any other programs).

Thanks,

Raj

Share this post


Link to post
Share on other sites
Valuater

Maybe...

$Program = "Myexefile.exe"

$Path = "C:\MyPath..."

$Runner = $Program & " " & $Path

MsgBox(4096,"", $Runner)

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
Valuater

Unless you plan to lock down a PC for some reason, that is usually a maulware trick. Care to share why you need to have this load before anything else?

I really think this is to run a file/argument... no?

8)

EDIT

Example...

@AutoItExe & $My_AU3_File

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites
sagdude

Unless you plan to lock down a PC for some reason, that is usually a maulware trick. Care to share why you need to have this load before anything else?

Hi Volly,

The reason is that I have a program whose behavior depends upon the number of arguments that are passed to it. I wrote a wrapper around it (I named the wrapper with the same name as the program). So, I want the wrapper to be called before the default program is called.

Also, if I have an exe file, is there anyway in which I can include the exe file and compile the autoit script, so that the resulting autoit exe doesnt need the original exe to run(in other words I want the compiled version of the script to be independent of the exe file that I include in the AutoIt script using Run()).

Thanks,

Raj

Share this post


Link to post
Share on other sites
GEOSoft

I really think this is to run a file/argument... no?

8)

EDIT

Example...

@AutoItExe & $My_AU3_File

I'm thinking along the lines of Volly here. The way I read it he wants to set the Path environment.

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
sagdude

I really think this is to run a file/argument... no?

8)

EDIT

Example...

@AutoItExe & $My_AU3_File

Hi

I want to modify the PATH environment variable. I want this program to run before any other program with a similar name.

Thanks,

Raj

Share this post


Link to post
Share on other sites
Valuater

Maybe..

Install the exe inside your script before compile

$MyProgram = @TempDir & "\MyAutoitexe.exe"
FileInstall("C:\MyAutoitexe.exe", $MyProgram)

; Later
Run($MyProgram & $arguments)

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites
Bert

you can include the exe in your script by using fileinstall. However, when your script runs, it will be confused by the fact you are trying to use the same exe name at the same time. I would rename the original exe with a _ at the start of it's name before compiling it.

Edited by Volly

Share this post


Link to post
Share on other sites
sagdude

you can include the exe in your script by using fileinstall. However, when your script runs, it will be confused by the fact you are trying to use the same exe name at the same time. I would rename the original exe with a _ at the start of it's name before compiling it.

Thanks for your reply Volly. May be some code will help clarify my point(or help me understand your point):

CODE
;;Form a command line argument string with the rest of the arguments

$argumentString = ""

For $i = 2 to $CmdLine[0] Step 1

$argumentString = $argumentString & $CmdLine[$i]

$argumentString = $argumentString & " "

Next

;

$commandString = "C:\rpctool.exe" & ' "' & $argumentString & '"'

Run(@ComSpec & " /c " & $commandString, "", @SW_HIDE)

Above is my wrapper script. The exe file I was referring to is C:\rpctool.exe

The reason I want to put this(the compiled version of this wrapper) in my path before anything else is that my users expect it to work with an optional first argument which is not needed by rpctool.exe program. So, I am just ignoring the first argument when creating the $argumentString.

Please let me know if you have any questions.

Thanks,

Raj

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.