Jump to content

Loading/Saving and commandline


Recommended Posts

I am having an odd issue with the run command.

Basically, I run an exe using its absolute path.

The exe is in the same folder as my script, so I simply wrote

Run('"' & @ScriptDir & '\myProg.exe"' some_arg)

And it works fine. some_arg is simply the argument that I need to pass to the exe, which is also located in the script dir

However, I then extended it to be able to load and save files (which is not the same as the scriptdir)

After loading or saving and trying to call the exe again, the exe doesn't seem to run.

I checked it and it is complaining that the required argument couldn't be found.

It seems like command-line starts up in the directory that the user saved or loaded the file from, and of course some_arg isn't there.

I could always specify the absolute path to some_arg, but how come command-line starts up somewhere else?

EDIT: hmm actually it seems I can't just specify the absolute path to the arg..

Edited by Tsukihime
Link to comment
Share on other sites

Hi there,

Why not set the script.exe in computer environment?

EnvSet

Cheers

Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Link to comment
Share on other sites

Run('"' & @ScriptDir & '\myProg.exe"' some_arg)
That code looks for some_arg in the current working directory.

However, I then extended it to be able to load and save files (which is not the same as the scriptdir)

After loading or saving and trying to call the exe again, the exe doesn't seem to run.

I checked it and it is complaining that the required argument couldn't be found.

It seems like command-line starts up in the directory that the user saved or loaded the file from, and of course some_arg isn't there.

Seems like you are perhaps using FileOpenDialog() and FileSaveDialog()? These function can change the working directory. I can only guess what the other code you may have to come to a conclusion.

Your code is looking for some_arg in @WorkingDir. For example of a working directory affecting a relative path in a command prompt

C:\>C:\temp\script.exe test.txt

The above will execute C:\temp\script.exe and will look for test.txt in C:\. It is looking in C:\ for text.txt because it inherits the current working directory from the command prompt. A working directory is inherited when your script starts and it can change through your script by some functions. It is up to you to control the working directory when using relative paths.

If your code is

FileChangeDir('C:\')
Run('C:\temp\script.exe test.txt')
Msgbox(0x40000, @Scriptname, @WorkingDir & '\text.txt')

I would expect the result in the Msgbox() to display the same path as where C:\temp\script.exe is working in and it should see text.txt. Perhaps this information may help you find an answer to your problem. :huh2:

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...