Jump to content
Sign in to follow this  
brian873

Run and external command help

Recommended Posts

brian873

Hi, I am new to the wonders of autoIT and after two days of searching through the forums I need help! Im stuck and digging a deepr hole for myself by the hour.

I have a small script I wrote that lists all the powerpoint files in a folder through a gui and then should pass on the selected file to a command that it will run with the external pptview application.

I can get the script to work if I manually type the file name. with the two methods below but I am stuck on how to pass the variable to the command line. I have tried numerous ways and now I feel I am going round in circles.

Run('pptview.exe /s copy of presentaion1.ppt', @scriptdir)

Run(@ComSpec & " /c " & 'pptview.exe /s "copy of presentation1.ppt"', "", @SW_HIDE)

I would imagine it to be something like

Run('pptview.exe /s & $SelctedFile, @scriptdir)

But I cant get it to work.!!!!

Any help would be appreciated.

Thanks

brian

Share this post


Link to post
Share on other sites
brian873

Hi hubertus, thanks for the reply.

Yes this works fine for files with no spaces in the name

ShellExecute('pptview.exe', "/s " & $s_text)

I never made clear in my last post that I need it to be able to handle file names with spaces ect (copy of presentation1.ppt)

Thanks again

Share this post


Link to post
Share on other sites
brian873

I have manage to complete what I want but I have to write the vairable to a txt file and use a batch command to run it using

FileWrite($file,$s_text)

FileClose($file)

Run(@ComSpec & " /c " & 'play.bat', "", @SW_HIDE)

I woudl love for AutoIT to be able to complete all this internally. Anyone?

Share this post


Link to post
Share on other sites
lordofthestrings

how about

$var_to_evaluate = "test test123"
if stringinstr($var_to_evaluate," ") then
    $var_to_evaluate = '"' & $var_to_evaluate & '"'
Else
    $var_to_evaluate = $var_to_evaluate
EndIf

Share this post


Link to post
Share on other sites
PsaltyDS

Hi hubertus, thanks for the reply.

Yes this works fine for files with no spaces in the name

ShellExecute('pptview.exe', "/s " & $s_text)

I never made clear in my last post that I need it to be able to handle file names with spaces ect (copy of presentation1.ppt)

Thanks again

Use single quotes to include double quotes as part of the string:

$s_text = 'copy of presentaion1.ppt'
ShellExecute('pptview.exe', ' /s "' & $s_text & '"')oÝ÷ Ù8^¥ªÚë^®ÊZ²Ç¶i¶øÁì^Â¥u·¡×¿³~¢¨~Þ±éíj*'ÖmßÜ¡×I8^½ªâi¹^˧ç²Æ«Ê'ò¢çhmÁ©í¶¬z+[ºÛ-Ygyçm¢ë²)àꮢ׬¶§rZ,^+^­©]¢æåz«¨µëºÚ"µÍÚ[^XÝ]J   ÌÎNÜY]Ë^IÌÎNË    ÌÎNÈÜÈ ][ÝØÛÜHÙÙ[Z[ÛK   ][ÝÉÌÎNÊ

:)

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
brian873

Thanks Lord of the strings. I have played about with that code but I am unsure what it is meant to do for me, can you explain to a auto it newbie.

thanks

Share this post


Link to post
Share on other sites
brian873

Many Thanks to Hubertus72 & PsaltyDS

I have go it working now without external batch files !

This is the part that had me stuck...

Use single quotes to include double quotes as part of the string:

Thanks again

brian

Share this post


Link to post
Share on other sites
PsaltyDS

This is the part that had me stuck...

Use single quotes to include double quotes as part of the string:

Just for completeness, I'll mention another good fix: FileGetShortName()

Returns the 8.3 format short name of the file that can use without double quotes:

$s_file = FileGetShortName(@ScriptDir & '\copy of presentaion1.ppt')
ShellExecute('pptview.exe', ' /s ' & $s_file) ; no double quotes needed

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
Shevilie

You couls actually do this

ShellExecute("pptview.exe", " /s ""ttt ttt.ppt""")

:)


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites
PsaltyDS

:D

Where'd you find the :ninja; smiley? That's cool, and it doesn't come up in my smiley list in the forum editor... :)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
lordofthestrings

$var_to_evaluate = "test test123"           ; var to evaluate, put space in it or not.
if stringinstr($var_to_evaluate," ") then       ; if in the string variable you find a space
    $var_to_evaluate = '"' & $var_to_evaluate & '"' ; enclose var to evaluate with double quotes
Else                            ; otherwise
    $var_to_evaluate = $var_to_evaluate         ; leave variable intact
EndIf                           ; end conditional statement.

sorry for late reply.

hope this code does what you need..

Edited by lordofthestrings

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  

×