Jump to content

How to run something from command prompt


Recommended Posts

Hi all,

My situation is a bit hard to explain but please bare with me. I'm trying to automate running a 3D benchmark (3DMark 2006). When I run it from command prompt as follows, the "ps" test automatically launches (the 3DMark 06 GUI is bypassed) and then exits after it's done.

C:\Program Files\Futuremark\3DMark06>3DMark06.exe -res=1280x1024 -ps - results.3dr

However, if I try to run it with a script, the 3DMark06 GUI pops up (it does actually select the "ps" test) but it just sits there and doesn't start:

Run($sProgramFiles & "\Futuremark\3DMark06\3DMark06.exe -res=1280x1024 -ps -results.3dr", $sProgramFiles & "\Futuremark\3DMark06")

I've tried ShellExecute but the result is the same. I'm not sure what the difference is between using "Run" or "ShellExecute" vs. running directly from command prompt but obviously the behavior is different.

My question is: how can I run it as though it's from command prompt so my test will start?

Thanks for any advice,

czhe

Link to comment
Share on other sites

ShellExecute should work perfect. It should look something like that:

ShellExecute($sProgramFiles & "\Futuremark\3DMark06\3DMark06.exe", "-res=1280x1024 " & "-ps " & "-results.3dr", $sProgramFiles & "\Futuremark\3DMark06")

It is not tested, but when i were needed to launch something with parameters similar codelines were working perfect.

Link to comment
Share on other sites

Just tried all three suggestions:

Run(@ComSpec & " /c " & 'commandName', "", @SW_HIDE)

Can't get this one to work at all. Not sure how I should take care of my directory.

ShellExecute($sProgramFiles & "\Futuremark\3DMark06\3DMark06.exe", "-res=1280x1024 " & "-ps " & "-results.3dr", $sProgramFiles & "\Futuremark\3DMark06")

This one does the exact thing as what I had before. It just pops up the GUI and stays there.

ShellExecute($sProgramFiles & "\Futuremark\3DMark06\3DMark06.exe", "-res=1280x1024 " & "-ps " & "-results.3dr", '"' & $sProgramFiles & "\Futuremark\3DMark06" & '"')

I can't get this to run. Script complains about not being able to find working directory.

And yes, my various $sProgramFiles is set to "C:\Program Files (x86)" for 64b OS and "C:\Program Files" for 32b OS.

What am I doing wrong? :idea:

Link to comment
Share on other sites

If you can run it from a command prompt then it gives you the information to use.

C:\>C:\Program Files\Futuremark\3DMark06\3DMark06.exe -res=1280x1024 -ps results.3dr

I removed a odd "-" on its own in the string so correct if needed.

I changed the ">" to "\" in the full path to 3DMark06.exe as I consider a typo mistake by you.

Let us just say the above works for you. The "C:\" is the current working directory of the command prompt taken from the prompt "C:\>". And with that, I would guess that the data file passed to 3DMark06.exe is in "C:\"? The data file in question is "results.3dr"?

So using Run() would be:

Run('"' & $sProgramFiles & '\Futuremark\3DMark06\3DMark06.exe" -res=1280x1024 -ps results.3dr', 'C:\')

Double quote the 1st parameter passed to Run, RunWait, RunAs, RunAsWait, ShellExecute, and ShellExecuteWait i.e. below.

Run('"path\to\file.exe" "parameter 1" parameter_2 "parameter 3"')

If the parameters (sometimes called switches) passed to "path\to\file.exe" do not have whitespace then double quotes are optional. The same option applies to the "path\to\file.exe" itself. If the variables or macros are used in the 1st parameter of Run() then use double quotes in case whitespace does exist.

Using @Comspec would be with the original line:

Run('"' & @Comspec & '" /c "C:\Program Files\Futuremark\3DMark06\3DMark06.exe" -res=1280x1024 -ps results.3dr', 'C:\')

All I did was put double quotes around "C:\Program Files\Futuremark\3DMark06\3DMark06.exe" as for the whitespace in the string. Then I put single quotes around the whole command string which also contains the switches. I even put double quotes around @Comspec as it is a macro which could have whitespace.

ShellExecute is similar to Run syntax though the switches have a seperate parameter to use. Thus the example below would be equivalent to the 1st use of Run() above.

ShellExecute('"' & $sProgramFiles & '\Futuremark\3DMark06\3DMark06.exe"', '-res=1280x1024 -ps results.3dr', 'C:\')

I put double quotes around the 1st parameter. The switches used in the 2nd parameter needed no double quotes so I opted to not use them. The working parameter does not use double quotes.

If you want to use or need the working directory of where 3DMark06.exe is, then you may need to specify the full path to results.3dr if it exists in a different directory. Let us assume that results.3dr exists in @MyDocumentsDir.

Run('"' & $sProgramFiles & '\Futuremark\3DMark06\3DMark06.exe" -res=1280x1024 -ps "' & @MyDocumentsDir & '\results.3dr"', $sProgramFiles & '\Futuremark\3DMark06')

Notice I put double quotes around the full path to results.3dr as @MyDocumentsDir may contain whitespace.

Hopefully I may have helped to solved your issue and explained how to handle double quoting as needed and working with a working directory that may help to achieve success. :idea:

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