Sign in to follow this  
Followers 0
brian873

Creating shortcuts

6 posts in this topic

I am trying to create a autoit script that creates a desktop icon pointing to a RDP server.

Everything work fine with the code below apart from the forward slashes "/" turning in to back slashes "\" and the extra "" in the shortcut.

This is taken from a desktop icon i created manually

%windir%\system32\mstsc.exe /f /v:merle.asp.esg-i.net:3390

This is waht is produced form the code below.

"C:\WINDOWS\system32\mstsc.exe \f \v:merle.asp.esg-i.net:3390"

Has anyone any idea why this happens?

Many thanks

brian

$FileName = "%windir%\system32\mstsc.exe /f /v:server1:3390"
$LinkFileName = @DesktopDir & "\Concept Connection.lnk"
$WorkingDirectory = @WindowsDir
$Icon = "C:\Windows\system32\SHELL32.dll"
$IconNumber = 67
$Description = "Concept Icon"
$State = @SW_SHOWMAXIMIZED ;Can also be @SW_SHOWNORMAL or @SW_SHOWMINNOACTIVE

FileCreateShortcut($FileName, $LinkFileName, $WorkingDirectory,"", $Description, $Icon,"", $IconNumber, $State)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

That's a path to a file, not a full command line. You should link to a .cmd file if you need to pass parameters, or even a compiled AutoIt script .exe file.

:)

Oops. Full command line still doesn't work as the file parameter, but the arguments can go in "args", as skyboy correctly pointed out below.

;)

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

Hi PsaltyDS, thanks for the reply :)

I am unsure what you mean.

If click START > RUN and paste in %windir%\system32\mstsc.exe /f /v:server1:3390 I get my desired result.

When I complie the code everythingy works fine, apart from the problem with the slashes reversing. So there should be no need to link to another file.

Any ideas?

thanks

brian

Share this post


Link to post
Share on other sites

FileCreateShortcut ( "file", "lnk" [, "workdir" [, "args" [, "desc" [, "icon" [, "hotkey" [, icon number [, state]]]]]]] )

you have the args set to an empty string, those thing after the .exe are arguments, drop them after the working directory and you'll be golden

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Hi,

see helpfile FileCreateShortcut. This should work:

$FileName = "%windir%\system\mstsc.exe"
;$FileName = @Systemdir & "\mstsc.exe" ; to work with autoit variables
$args = "/f /v:server1:3390"
$LinkFileName = @DesktopDir & "\Concept Connection.lnk"
$WorkingDirectory = "%windir%" ; you shouldn't mix up AutoIT Varaibles and systemvariables
;$WorkingDirectory = @WindowsDir ; to work with autoit variables
$Icon = "%windir%\system32\SHELL32.dll"
;$Icon = @WindowsDir & \system32\SHELL32.dll"
$IconNumber = 67
$Description = "Concept Icon"
$State = @SW_SHOWMAXIMIZED ;Can also be @SW_SHOWNORMAL or @SW_SHOWMINNOACTIVE

FileCreateShortcut($FileName, $LinkFileName, $WorkingDirectory, $args, $Description, $Icon,"", $IconNumber, $State)

;-))

Stefan

P.S: Slower then skyboy

Edited by 99ojo

Share this post


Link to post
Share on other sites

Hi skyboy,

thanks thats exactly what it was! I think i spent to much time staring at it to see the problem :)

this version works perfect

$FileName = "%windir%\system32\mstsc.exe"
$Args = " /f /v:server1:3390"
$LinkFileName = @DesktopDir & "\Concept Connection.lnk"
$WorkingDirectory = @WindowsDir
$Icon = "C:\Windows\system32\SHELL32.dll"
$IconNumber = 67
$Description = "Concept Icon"
$State = @SW_SHOWMAXIMIZED ;Can also be @SW_SHOWNORMAL or @SW_SHOWMINNOACTIVE

FileCreateShortcut($FileName, $LinkFileName, $WorkingDirectory, $args, $Description, $Icon,"", $IconNumber, $State)

Stephan,

haha just tested skyboys, pretty much same as your answer.

Thanks both for quick replys! ;)

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