Sign in to follow this  
Followers 0
prp2

How to run an exe with command-line switches?

5 posts in this topic

Hello folks,

I'm trying to run a program that takes some command-line switches to force an installation over a current one. If I just run the program as-is it works fine, but when I try to run it with the switch, it doesn't seem to be accepting it and just runs normally.

What I've done so far is:

Run (@TempDir & '\prog.exe')

That just runs it as-is, with no switches.

But when I try:

Run (@TempDir & '\prog.exe /force')

That also just runs it as-is, as if I didn't use a switch.

Lastly I tried:

Run (@TempDir & '\prog.exe' & '/force')

I didn't really expect that one to work, and it didn't, saying it couldn't find the program to run.

Am I doing something wrong?

Share this post


Link to post
Share on other sites



1

is the program.exe located under c:\documents and settings\username\temp folder??... thats what @tempDir means

2

Run (@TempDir & '\prog.exe' & '/force') is missing a space .... it should be Run (@TempDir & '\prog.exe' & ' /force')

3

try ShellExecute()

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hello folks,

I'm trying to run a program that takes some command-line switches to force an installation over a current one. If I just run the program as-is it works fine, but when I try to run it with the switch, it doesn't seem to be accepting it and just runs normally.

What I've done so far is:

Run (@TempDir & '\prog.exe')

That just runs it as-is, with no switches.

But when I try:

Run (@TempDir & '\prog.exe /force')

That also just runs it as-is, as if I didn't use a switch.

Lastly I tried:

Run (@TempDir & '\prog.exe' & '/force')

I didn't really expect that one to work, and it didn't, saying it couldn't find the program to run.

Am I doing something wrong?

Not sure about the issue with the force switch for your particular app, but the last example you gave would need another space inside your quotes, because right now it would end up passing \prog.exe/force. Other than that your syntax looks fine.

Edited by Monamo

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Share this post


Link to post
Share on other sites

Ahh, as it turns out, the /force flag I was using doesn't do exactly that. It does reinstall files over existing ones, but it also prompts the user for settings. I ended up using an If...Then...Else for it. Seems to work well enough now. Thanks for the help. :)

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