Jump to content
Sign in to follow this  
kman

Running from desktop shortcut

Recommended Posts

kman

Hello everyone.

I am trying to create an automated install of client software and part of it includes a first run of the application by double clicking on the shortcut on the desktop then entering in a username - password - database field to connect. I thought this would be simple enough with the following:

Run(@ComSpec & ' /c "C:\Documents and Settings\All Users\Desktop\My.lnk"')

WinWait("Window Title","Text")

Sleep(1000)

ControlSend("Window Title","Text","Edit1","username")

Sleep(1000)

ControlSend("Window Title","Text","Edit2","password")

Sleep(1000)

ControlSetText("Window Title","Text","Edit3","")

Sleep(1000)

ControlSend("Window Title","Text","Edit3","database connection")

Sleep(500)

ControlClick("Window Title","Text","Button1") ;this is the OK button

This all seems to work except the program tells me it cannot connect to the database. This only happens by running the Run(@ComSpec & ' /c "C:\Documents and Settings\All Users\Desktop\My.lnk"') line. If I take that line out, run the script so it sits at the first WinWait line then physically double click the shortcut, the script takes over and works the way I need. What is the difference between physically clicking the shortcut or having autoit tell it to run? Any ideas on how to resolve this? Thanks for any help and let me know if more clarification is needed.

Share this post


Link to post
Share on other sites
Valuater

1 WinWait()

Waits for that window to show before continuing

2 try this

ShellExecute("C:\Documents and Settings\All Users\Desktop\My.lnk", "", @WorkingDir)

.........check the "arguments".................................................................^^

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites
kman

Sorry, still unable to login with that.

When you say check the arguments, do you mean the arguments with FileGetShortcut?

Share this post


Link to post
Share on other sites
someone

What Val meant was to chceck the arguments of shellexecute. This code will launch an internet explorer shortcut on my desktop...

ShellExecute("C:\Documents and Settings\Andrew\Desktop\Internet Explorer.lnk")

Try that with your path and see what happens.


While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd

Share this post


Link to post
Share on other sites
kman

Yes, I did try that in place of Run(@ComSpec & ' /c "C:\Documents and Settings\All Users\Desktop\My.lnk"'). It did launch my application but still does not login like physically double clicking the shortcut.

Share this post


Link to post
Share on other sites
someone

Thats odd... can you be more descriptive about what its doing? Is it possible the machine would have some sort of protection against a script running?

Hmm...

Try ShellExecute with the 'verb' parameter and/or some of the other options. Let us know how it goes.


While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd

Share this post


Link to post
Share on other sites
cryn

Sorry but is there reason why you prefer using a shortcut then actually putting the target information to a Run or Shellexecute function?

Share this post


Link to post
Share on other sites
kman

Not sure if this makes a difference but I am trying to run an .exe on a separate server. I have tried to use different run commands, such as, Run("\\Server\Folder\Program.exe"), but trying to tell this program to run, it tells me I am unable to connect to the database, for the life of me I dont know why double clicking this shortcut works but telling it to run from autoit does not allow me to connect. I can connect correctly by going Start-Run-\\Server\Folder\Program.exe

Share this post


Link to post
Share on other sites
cryn

Try giving the working directory.

Run ('\\server\folder\program.exe','\\server\folder\',@SW_SHOW)

Share this post


Link to post
Share on other sites
kman

The only way I could ever get it to work was by having the script open the run box then filling in the text of the server and app.exe then telling it ok. I dont know what that was the only way it would work. But its doing what I need. Thanks for everyones 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  

×