Sign in to follow this  
Followers 0
ragemxf

create a shortcut to a program automatically with script

19 posts in this topic

I have to deploy a lot of pc's and on every one of them I have to login as user and change a shortcut so the parameter to the program reflects the user logged on...

"c:\windows\notepad.exe" Neal Smith

I have the logged on user in $var on clipPut

so if I wrote a script to open the properties for this shortcut I can tell it to paste from clipboard.

What I am really trying to do is create a brand new shortcut that will put my variable in a as parameter?

Can this be done?

Share this post


Link to post
Share on other sites



I have to deploy a lot of pc's and on every one of them I have to login as user and change a shortcut so the parameter to the program reflects the user logged on...

"c:\windows\notepad.exe" Neal Smith

I have the logged on user in $var on clipPut

so if I wrote a script to open the properties for this shortcut I can tell it to paste from clipboard.

What I am really trying to do is create a brand new shortcut that will put my variable in a as parameter?

Can this be done?

Look at FileGetShortcut and FileCreateShortcut

B)


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I have to deploy a lot of pc's and on every one of them I have to login as user and change a shortcut so the parameter to the program reflects the user logged on...

"c:\windows\notepad.exe" Neal Smith

I have the logged on user in $var on clipPut

so if I wrote a script to open the properties for this shortcut I can tell it to paste from clipboard.

What I am really trying to do is create a brand new shortcut that will put my variable in a as parameter?

Can this be done?

Why are you posting what I already posted?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Why are you posting what I already posted?

don't understand ....

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

summary....

I want to create a shortcut using autoit... without using windows gui

Share this post


Link to post
Share on other sites

Um... He was simply replying to your question if you look at the Quote, and when you click reply it automatically quotes what your replying to.

He gave you the items to look at too.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

JdeB simply quoted your post... (there are many reason to quote like that, but that is not the topic of this thread - you can bring that up in a new post in the Chat area if you are curious as to why people post the way that they do.)

JdeB also gave you the answer to your question.

There was no GUI in his answer.

You want the shortcut's target line to "reflect the user logged on".

You can do this best with the answer that JdeB gave.

What part of that answer do you not understand?

Do you need help understanding FileCreateShortcut?


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

I am sorry... you are all right... I did not see the items he left at the bottom of the post... I have looked at the FileCreateShortcut and this will work perfect......

Thank You everyone

Share this post


Link to post
Share on other sites

...I did not see the items he left at the bottom of the post...

Understood. Just one of the drawbacks to a full quote.

This code uses " Neal Smith" as text. Let's hope that you can replace that with @UserName

FileCreateShortcut(@WindowsDir & "\notepad.exe", _
        @DesktopDir & "\Shortcut Test.lnk", _
        @WindowsDir, " Neal Smith", "", _
        @SystemDir & "", "", "", @SW_

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

everything works but the working dir..... it puts my working directory in the "Batch file" section, winxp sp2.

my working dir is q:

filecreateshortcut("c:\aimstempct\usrip400.exe","C:\data\","q:",@username)

only when I check the shortcut after autoit creates... the q: goesinto "batch file" and "working dir" is empty

what now?

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Where is your "lnk" parm?

Full path and file name of the shortcut.

$file = "c:\aimstempct\usrip400.exe"
$lnk = "C:\temp\test.lnk"
$workdir = "C:\data\"
$args  =  "q:\" & @username

FileCreateShortcut ($file, $lnk, $workdir, $args)
Edit: I just guessed at what goes where - edit the variables to suite your needs. Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

here is my latest script

filecreateshortcut("c:\aimstempct\usrip400.exe","C:\program files\commodity folder\C&T\Aims Application.pif","q:",@username,"Aims Application","C:\AIMSTEMPCT\SPCESHP.ICO")

q: should be working directory......but it does not go into working dir like it should

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

'"C:\program files\commodity folder\C&T\Aims Application.pif"'

Add single quotes around this parm.

Just a guess...

I like my format ;-)

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Okay, so this code does NOT work for me.

Anyone else want to jump in and offer a suggestion?

$file = "c:\aimstempct\usrip400.exe"
$lnk = '"C:\program files\commodity folder\C&T\Aims Application.pif"'
$workdir = "q:"
$args  =  @username
$desc = "Aims Application"
$icon = "C:\AIMSTEMPCT\SPCESHP.ICO"

FileCreateShortcut ($file, $lnk, $workdir, $args, $desc, $icon)
Edit: ...and yes, I made this folder C:\Program Files\commodity folder\C$T Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Okay, so I led myself astray. This code does work for me... not sure why:

$file = "c:\aimstempct\usrip400.exe"
$lnk = "C:\Program Files\commodity folder\C$T\Aims Application.pif"
$workdir = "q:"
$args  =  @username
$desc = "Aims Application"
$icon = "C:\AIMSTEMPCT\SPCESHP.ICO"

FileCreateShortcut ($file, $lnk, $workdir, $args, $desc, $icon)

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

q: should be working directory......but it does not go into working dir like it should

Using your latest one line version - it works for me.

q: is where it should be - "Start in:"

What operating system are you using when you run this line of code?


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

what is the difference between the two?

Share this post


Link to post
Share on other sites

figured it out.... I had to map my q: drive before I created the shortcut... thats why..

Thanks everyone

Share this post


Link to post
Share on other sites

what is the difference between the two?

Glad you got it to work for you. (There is no difference between the way that you wrote it and the way I broke it out. I just found it easier to see what was what in the format that I used. Then it dawned on me that I had not tested your last script "as is" in your format. I tested it and thought it was worth the post to confirm no errors with your code on my system. But we must be using different operating systems, since it worked for me without having a drive mapped.)

[size="1"][font="Arial"].[u].[/u][/font][/size]

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