Jump to content

Please give me example of using this?


Recommended Posts

How would you use this in a script? "@MyDocumentsDir" I've searched everywhere but can't find the answer. I'd like to create a shortcut for my program using autoit and would like to know how to place that into my documents folder. Please help me.

Edited by krzyrice
Link to comment
Share on other sites

maybe this:

$FileExe = FileOpenDialog("select file", "C:\", "Executable (*.exe)")
if @error = 1 then Exit ;cancel has been clicked
$stringSplit = StringSplit ( StringTrimRight($FileExe, 4), "\")
$count = $stringSplit[0]
$ShortcutName = InputBox("Shorcut Name", "Input name of your new shortcut:", $stringSplit[$count])
if @error = 1 then Exit ;cancel has been clicked
FileCreateShortcut($FileExe, @MyDocumentsDir & "\" & $ShortcutName & ".lnk")
MsgBox(0, "Shortcut Creator", "New shortcut for your " & $stringSplit[$count] & " program has been created" _
        & @CRLF & "Location: " & @MyDocumentsDir & "\" & $ShortcutName & ".lnk")
Edited by sandin
Link to comment
Share on other sites

How would you use this in a script? "@MyDocumentsDir" I've searched everywhere but can't find the answer. I'd like to create a shortcut for my program using autoit and would like to know how to place that into my documents folder. Please help me.

$FileName = "C:\FooBar.txt"
$LinkName = "Link to FooBar.txt.lnk"
$handle = FileOpen($FileName, 2)
FileWriteLine($handle, "I'm just a file, leave me alone!")
FileClose($handle)

FileCreateShortcut($FileName, @MyDocumentsDir & "\" & $LinkName, @MyDocumentsDir)
Run("explorer.exe /e,/select," & @MyDocumentsDir & "\" & $LinkName)

Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...