Jump to content
Sign in to follow this  
failedtocompile

Run exe with arguments /q /s

Recommended Posts

failedtocompile

Greetings :D

Im a novice with AutoIT and have been struggling with an element within my script.

I have read the Help file "CMDline" "DOS" and have read over 20 different forum posts with regards to the issue im having. Not one of the avenues I have tried to source for support has helped, possibly due to my lack of understanding.

This is what Im working on

#Majority of the leading code has been removed, as this is a private not for profit project {failedtocompile}

    Run("""""C:\Program Files\???\WIZ.EXE""/q /s ""%HomeDrive%%homepath%\folder\folder""""")
;RunWait("""C:\Program Files\???\WIZ.EXE""/q /s ""%HomeDrive%%homepath%\folder\folder""") <<temporraly commented out while testing both methods
    sleep(10000)
EndSwitch
WEnd

The GUI executes perfectly the only issue I am having is trying to Run or RunWait "ROFLWIZ.EXE" with arguments /q /s {/q for silent} {/s for file to save to}

Have also looked at

$CmdLine[0] is number of parameters

$CmdLine[1] is param 1 (after the script name)

$CmdLine[2] is param 2 etc

...

$CmdLine[$CmdLine[0]] is one way to get the last parameter...

But I'm not sure how to apply this correctly to suit my porpose.

If I remove the /q it works very well but just adding that additional argument nothing happens, No errors and doesnt create the file.

I have also tried adding triple quotes quad quotes.

I will be eventually changing %HomeDrive%HomePath% to just %homePath%

I have spent over 5hrs today learning to create GUI and trying to progress further with AutoIT, I must say I have enjoyed it thus far

If anyone could shine a "light" for a poor and distressed Novie, It would be greatly appreciated

Kind Regards

failedtocompile

Share this post


Link to post
Share on other sites
martin

Greetings :D

Im a novice with AutoIT and have been struggling with an element within my script.

I have read the Help file "CMDline" "DOS" and have read over 20 different forum posts with regards to the issue im having. Not one of the avenues I have tried to source for support has helped, possibly due to my lack of understanding.

This is what Im working on

#Majority of the leading code has been removed, as this is a private not for profit project {failedtocompile}
 
     Run("""""C:\Program Files\???\WIZ.EXE""/q /s ""%HomeDrive%%homepath%\folder\folder""""")
;RunWait("""C:\Program Files\???\WIZ.EXE""/q /s ""%HomeDrive%%homepath%\folder\folder""") <<temporraly commented out while testing both methods
     sleep(10000)
 EndSwitch
 WEnd

The GUI executes perfectly the only issue I am having is trying to Run or RunWait "ROFLWIZ.EXE" with arguments /q /s {/q for silent} {/s for file to save to}

Have also looked at

$CmdLine[0] is number of parameters

$CmdLine[1] is param 1 (after the script name)

$CmdLine[2] is param 2 etc

...

$CmdLine[$CmdLine[0]] is one way to get the last parameter...

But I'm not sure how to apply this correctly to suit my porpose.

If I remove the /q it works very well but just adding that additional argument nothing happens, No errors and doesnt create the file.

I have also tried adding triple quotes quad quotes.

I will be eventually changing %HomeDrive%HomePath% to just %homePath%

I have spent over 5hrs today learning to create GUI and trying to progress further with AutoIT, I must say I have enjoyed it thus far

If anyone could shine a "light" for a poor and distressed Novie, It would be greatly appreciated

Kind Regards

failedtocompile

Looks like you need a space added which could be part of the problem

" /q..."
;instead of
"/q..."

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
failedtocompile

Looks like you need a space added which could be part of the problem

" /q..."
;instead of
"/q..."

Thanks martin, its one step closer :D

Problem I have still and forgot to mention is that when executed it saves it to: C:\Program Files\?? ??\WIZ.EXE\%HomeDrive%%homepath%\folder\folder instead of %HomeDrive%%Homepath%\folder\folder {C:\Documents and settings\profile\my documents\folder\filename}

If i run the same Exe in a dos prompt

Dos:

"C:\Program Files\?? ???\WIZ.EXE"/q /s "desired folder destination\file"      {/q directly after the " no spaces /s one space after /q}

It works great, I have a working batch file

I have tried multiple combination of adding and removing "" , which i dont really understand

I also saw a post someone wanted to know how to run an .msi with arguments for silent install, i thought it was similar but was unable to apply it to mine

Cheers

Edited by failedtocompile

Share this post


Link to post
Share on other sites
failedtocompile

I have just tried

RunWait('"C:\Program Files\?? ??\?? ??\WIZ.EXE" /q /s ' & 'c:\test123')

This seems to have worked only problem is that it doesnt work if the folder path has spaces in it

example

RunWait('"C:\Program Files\?? ??\?? ??\WIZ.EXE" /q /s ' & '"%homedrive%%HomePath%\My Documents\test101"')

Anyone able to help me? do i need to place more quotes somehere?

Cheers

Edited by failedtocompile

Share this post


Link to post
Share on other sites
BrettF

Are you sure everything is fine with %homedrive% and the like?

Try something like so:

Opt('ExpandEnvStrings', 1)
RunWait('"C:\Program Files\BLAH\WIZ.EXE" /q /s "%homedrive%%HomePath%\My Documents\test101"')

Share this post


Link to post
Share on other sites
failedtocompile

Are you sure everything is fine with %homedrive% and the like?

Try something like so:

Opt('ExpandEnvStrings', 1)
RunWait('"C:\Program Files\BLAH\WIZ.EXE" /q /s "%homedrive%%HomePath%\My Documents\test101"')

Hi BrettF

I tried you example obviosuy amending, but nothing happens. for a split second show hr glass as if it was thinking about executing the command.

RunWait('"C:\Program Files\?? ??\folder\WIZ.EXE" /q /s "%homedrive%%HomePath%\My Documents\test101"')

It all seems to come back to having spaces in destination path and have multiple arguments /q /s

as mentioned prior works in batch file format and both /s and /q are vaild arguments

Edited by failedtocompile

Share this post


Link to post
Share on other sites
BrettF
failedtocompile

Does this work?

RunWait("C:\Program Files\?? ??\folder\WIZ.EXE /q /s " & @MyDocumentsDir & "\test101")

Bah, I was looking for that, but I guess I didn't scroll down far enough.

No sorry didnt have desired effect :D

What it did do tho was pop up a window detailing vaild arguments like what would happen if you droped a M$ .exe in cmd and tacked /? at the end e.g. "C:\Program Files\?? ??\folder\WIZ.EXE"/? would produce a window detailing vaild arguments and what they do ect...

Have attached SS of window that pops up.

Thnx thus far for your assistance

post-50705-1244951737_thumb.jpg

Edited by failedtocompile

Share this post


Link to post
Share on other sites
failedtocompile

Okay, if I understand that correctly, the problem is that you need to specify an "OPS file" for the "/s" parameter. Right now you only have a directory.

Try this.

RunWait("C:\Program Files\?? ??\folder\WIZ.EXE /q /s " & @MyDocumentsDir & "\test101\Test.OPS")
Thnx Thanubis

but doesnt @MyDocumentsDir define a directory structure hence @MyDocumentsDir & "\test101\ = c:\documents and settings\profile\my documents\test101

Also your example unfortunatly didnt work again displays the screen shot a posted. the problem seems to be when having 2x arguments and "if" the folder structure i want to save the file to has spaces in the name.

This problem seems like a real douzy :D

currently clocked up 7hrs reading forum posts trying to find relevence

Share this post


Link to post
Share on other sites
failedtocompile

Some Google searching revealed that the /s parameter file path must be enclosed in quotes if it contains a space. I don't know why I didn't notice it sooner (maybe because it's 4AM), but my quotes have been screwed this whole time. Also, /s and / q can be used together without a problem.

I think I've got it right this time.

RunWait('"C:\Program Files\?? ??\folder\WIZ.EXE" /q /s "' & @MyDocumentsDir & '\test101\Test.OPS"')

WOOOOT

Thanks so much Thanubis you are a bloody star :D that worked, also you shouldnt stay up too late on my account :P that is a bit obsessive :D lol

Have posted ss of my first application i have ever created in Autoit, will add ur name to the code for assisting me with this one mate ;)

Share this post


Link to post
Share on other sites
rajeshontheweb

if u feel u will have spaces in the directory names it is BETTER to use short names only for dos prompt as even in windows xp (which case spaces are supported) there is a chance some times the path fails due to some minor errors ..

use the functionFileGetShortName ( "file" [, flag] )

try to see if this works

Local $ProgramFile, $argFile
$ProgramFile = FileGetShortName("C:\Program Files\?? ??\folder\WIZ.EXE")
$argFile = FileGetShortName(@MyDocumentsDir & "\test101\Test.OPS")
$command = "'" & chr(34) & $ProgramFile & Chr(34) & " /q /s " & chr(34) & $argFile & chr(34) & "'"
Runwait($command)

but one catch is there , which is usually ignored - shortnames differ from one pc to other so they better not be hard coded into a variable that is used in different situations, it should be called on the host computer and at the time of execution only, which will cover any unexpected errors due to a deleted file or some thing like that

Edited by rajeshontheweb

Share this post


Link to post
Share on other sites
failedtocompile

if u feel u will have spaces in the directory names it is BETTER to use short names only for dos prompt as even in windows xp (which case spaces are supported) there is a chance some times the path fails due to some minor errors ..

use the functionFileGetShortName ( "file" [, flag] )

try to see if this works

Local $ProgramFile, $argFile
$ProgramFile = FileGetShortName("C:\Program Files\?? ??\folder\WIZ.EXE")
$argFile = FileGetShortName(@MyDocumentsDir & "\test101\Test.OPS")
$command = "'" & chr(34) & $ProgramFile & Chr(34) & " /q /s " & chr(34) & $argFile & chr(34) & "'"
Runwait($command)

but one catch is there , which is usually ignored - shortnames differ from one pc to other so they better not be hard coded into a variable that is used in different situations, it should be called on the host computer and at the time of execution only, which will cover any unexpected errors due to a deleted file or some thing like that

Thanks rajeshontheweb

Will keep that snipet for latter implementation. all computers are goign to be in a standard environment XPSP3 all with Mydocuments being stored on a server e.g. \\server2003\userprofile\My Documents. Will be doing more testing tomorrow,

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  

×