Jump to content

@WorkingDir


Recommended Posts

Dear Sir

there is a line in my script showed below

$myChildAPP = Run("SMS_1.exe", @WorkingDir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD)

she works well now , but

my question is :

1)

suppose there are 2 .exe file in user's PC with the same name "SMS_1" then

which .exe file would be run ?

2)

the parameter @WorkingDir could be any path i want , am i right ?

thanks

Link to comment
Share on other sites

No. The working dir is something different. There can't be two files with the same name in the same directory. The .exe's path is taken from the first parameter.

Run("notepad.exe", @WorkingDir)
Run("notepad.exe", "C:\")

I'm guessing this gives you 2 notepads.

Link to comment
Share on other sites

No. The working dir is something different. There can't be two files with the same name in the same directory. The .exe's path is taken from the first parameter.

Run("notepad.exe", @WorkingDir)
Run("notepad.exe", "C:\")

I'm guessing this gives you 2 notepads.

thank you , and

why when we

Run("notepad.exe", $somepath)

not need indicate the full path of notepad.exe ?

Link to comment
Share on other sites

thank you , and

why when we

Run("notepad.exe", $somepath)

not need indicate the full path of notepad.exe ?

Because Notepad is in the Windows Directory, if you had a notepad on d: which was something eles you'd have to specify d:\Notepad.exe but if you just used Notepad.exe then the one in the windows directory would run.

You could run both and have both of them using hte same Working Directory but they would have different run paths Run("D:\Notepad.exe",$somepath) and Run ("Notepad.exe",$SomePath)

Edited by ChrisL
Link to comment
Share on other sites

Because Notepad is in the Windows Directory, if you had a notepad on d: which was something eles you'd have to specify d:\Notepad.exe but if you just used Notepad.exe then the one in the windows directory would run.

You could run both and have both of them using hte same Working Directory but they would have different run paths Run("D:\Notepad.exe",$somepath) and Run ("Notepad.exe",$SomePath)

thank you , and

could we put my .exe file to the Windows Directory ?

where it is ?

any other steps i need to know ?

Link to comment
Share on other sites

thank you , and

could we put my .exe file to the Windows Directory ?

where it is ?

any other steps i need to know ?

BigDog,

notepad is not starting without the full path because of being in the windws directory(though ist is)

it is starting because it is in you PATH.

So if you PATH environment variable is

C:\DIR1;C:\WINDOWS

and C:\DIR1 contains a NOTEPAD.exe, it is this one which will be started, until it is deleted or the PATH

var is changed.

Edited by womue
Link to comment
Share on other sites

thank you , and

could we put my .exe file to the Windows Directory ?

where it is ?

any other steps i need to know ?

Yeah you can put your file in the windows directory if you want but if you have 2 files with the same name then you'll have to have them in 2 different locations/directories or make sure they have different names.

I personally wouldn't put my exe's in the Windows directory I would specify the full path to my files in my folder elsewhere

Link to comment
Share on other sites

BigDog,

notepad is not starting without the full path because of being in the windws directory(though ist is)

it is starting because it is in you PATH.

So if you PATH environment variable is

C:\DIR1;C:\WINDOWS

and C:\DIR1 contains a NOTEPAD.exe, it is this one which will be started, until it is deleted or the PATH

var is changed.

Go Start\Run\Notepad and Notepad would run

Try doing that with a file somewhere else in a folder on your desktop and it wont find it

$somepath has nothing to do with running the file it is only the directory to use as a working directory.

You could run a file from D:\Myfile.exe and set the working path to C:\Windows then any resourses that were specified in the program which used relevant paths would be loaded from the working directory of C:\Windows

However you can specify new Application paths in HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\App Paths

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...