TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: @_Bilal on February 12, 2019, 07:19:31 PM

Title: Running shortcut with autolisp
Post by: @_Bilal on February 12, 2019, 07:19:31 PM
Hi Guys,

Someone can help me to run from AutoLISP using Shell object the following shortcut
Target: C:\Users\Myfolder\updater.exe /checknow

thank you in advance
Title: Re: Running shortcut with autolisp
Post by: MP on February 12, 2019, 07:57:38 PM
A bit long in the tooth and I don't have time to test if it still works but the shortcut portion of this code worked way back when ... link (http://www.theswamp.org/index.php?topic=25051.msg301679#msg301679[/url).
Title: Re: Running shortcut with autolisp
Post by: Lee Mac on February 13, 2019, 08:23:20 AM
This?

Code: [Select]
(command "_.shell" "C:\\Users\\Myfolder\\updater.exe /checknow")
Title: Re: Running shortcut with autolisp
Post by: JohnK on February 13, 2019, 08:41:54 AM
The original question is a little confusing--and I think Lee has already answered it but if the question is: "how to create a shortcut with lisp", I had this in one of my old files. You will have to update the information to suit your needs.

Code - Auto/Visual Lisp: [Select]
  1. ( (lambda ( / sh shorcutlnk)
  2.     ;; how to create a shortcut with Visual Lisp
  3.     (setq sh
  4.           (vla-getInterfaceObject
  5.             (vlax-get-acad-object) "WScript.Shell")
  6.           shortcutlnk (vlax-invoke-method sh 'CreateShortcut (strcat "C:\\Documents and Settings\\" (getvar 'LOGINNAME) "\\Desktop\\AutoCAD MEP (US Imprerial).lnk")))
  7.     (vlax-put-property shortcutlnk 'TargetPath "\\Program Files\\ABS2008\\acad.exe\" /ld \"C:\\Program Files\\ABS2008\\AecBase.dbx\" /p \"AutoCAD (Mech)")
  8.     (vlax-put-property shortcutlnk 'IconLocation "%SystemRoot%\\Installer\\{5783F2D7-6006-0409-0002-0060B0CE6BBA}\\abs2008.ico, 0")
  9.     (vlax-put-property shortcutlnk 'WindowStyle 1)
  10.     (vlax-put-property shortcutlnk 'Hotkey "")
  11.     (vlax-put-property shortcutlnk 'Description "Launch AutoCAD MEP 2008 with Company Profile")
  12.     (vlax-invoke-method shortcutlnk 'Save)
  13.     (vlax-release-object shortcutlnk)
  14.     )
  15.  )
Title: Re: Running shortcut with autolisp
Post by: @_Bilal on February 13, 2019, 09:56:52 AM
Tanks for All

The target file "updater.exe" resides in
"C:\\Users\\username\\AppData\\Roaming\\softwareFolder\\updater.exe"
While the shortcut "soft_Updater.lnk" resides in
"C:\\Users\\username\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\softwareFolder\\soft_Updater.lnk"

When i ran the updater.exe file from the target directly
(command "_.shell" "C:\\Users\\username\\AppData\\Roaming\\softwareFolder\\updater.exe")
failed result:-------the cmd screen run then close immediatetly

(command "_.shell" "C:\\Users\\username\\AppData\\Roaming\\softwareFolder\\updater.exe /checknow")
success result:-------But two screens run at the same time one is cmd screen and the other is for updater.exe

when trying to run the shortcut "soft_Updater.lnk"
(command "_.shell" "C:\\Users\\username\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\softwareFolder\\soft_Updater.lnk")
failed result:-------the cmd screen run then close immediatetly

When using Lee Mac function
(LM:Open "C:\\Users\\username\\AppData\\Roaming\\softwareFolder\\updater.exe")
return T:-------but nothing happens.

(LM:Open "C:\\Users\\username\\AppData\\Roaming\\softwareFolder\\updater.exe /checknow")
Return nil

(LM:Open "C:\\Users\\username\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\soffold\\soft_Updater.lnk")
Return T:------------the updater.exe run alone without the cmd screen. Which is perfect

What i am looking for is to run (LM:open "C:\\Users\\username\\AppData\\Roaming\\softwareFolder\\updater.exe /checknow")
is it possible?
Title: Re: Running shortcut with autolisp
Post by: VovKa on February 13, 2019, 10:31:43 AM
no Shell
Code: [Select]
(startapp "C:\\Users\\username\\AppData\\Roaming\\softwareFolder\\updater.exe" "/checknow")
Title: Re: Running shortcut with autolisp
Post by: MP on February 13, 2019, 12:27:58 PM
Absolute VovKa. :)
Title: Re: Running shortcut with autolisp
Post by: @_Bilal on February 13, 2019, 03:05:09 PM
Great,

(startapp "C:\\Users\\username\\AppData\\Roaming\\softwareFolder\\updater.exe" "/checknow")
success result:-------------updater.exe run in a proper manner

Thanks, Vovka, and Thanks every budy