Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Scripting > Shortcut on desktop via logon?

Reply
Thread Tools Display Modes

Shortcut on desktop via logon?

 
 
Linn Kubler
Guest
Posts: n/a

 
      10-02-2008
Hi,

I've been asked to distribute a shortcut to a web site to all my users. I
think the best way to do this is through the logon.bat file, however, I'm
stuck, can't seem to figure it out. It seemed simple enough, just add the
following code to my batch file, right?

If Not Exist %ALLUSERSPROFILE%\Desktop\PI.lnk (Copy PI.lnk
%ALLUSERSPROFILE%\Desktop)

Of course this doesn't work. Can someone show me how to handle this in the
simplest way possible? I've been Googling the solution and I'm not finding
anything useful, just confusing.

The PI.lnk file is currently located in the DC Netlogon directory.

As a test I modified the line to look like this below and put a test.txt
file on the All Users Desktop on my test system.

If Not Exist %ALLUSERSPROFILE%\Desktop\test.txt (Echo "It's not there!")
Else (Echo "It's there!")

From this line I get no response in my batch file output. I'm clearly
missing something fundamental here. Any thoughts, words of wisdom?

Thanks in advance,
Linn


 
Reply With Quote
 
 
 
 
Pegasus \(MVP\)
Guest
Posts: n/a

 
      10-02-2008

"Linn Kubler" <> wrote in message
news:OzCi$...
> Hi,
>
> I've been asked to distribute a shortcut to a web site to all my users. I
> think the best way to do this is through the logon.bat file, however, I'm
> stuck, can't seem to figure it out. It seemed simple enough, just add the
> following code to my batch file, right?
>
> If Not Exist %ALLUSERSPROFILE%\Desktop\PI.lnk (Copy PI.lnk
> %ALLUSERSPROFILE%\Desktop)
>
> Of course this doesn't work. Can someone show me how to handle this in
> the simplest way possible? I've been Googling the solution and I'm not
> finding anything useful, just confusing.
>
> The PI.lnk file is currently located in the DC Netlogon directory.
>
> As a test I modified the line to look like this below and put a test.txt
> file on the All Users Desktop on my test system.
>
> If Not Exist %ALLUSERSPROFILE%\Desktop\test.txt (Echo "It's not there!")
> Else (Echo "It's there!")
>
> From this line I get no response in my batch file output. I'm clearly
> missing something fundamental here. Any thoughts, words of wisdom?
>
> Thanks in advance,
> Linn
>


Since the string
%ALLUSERSPROFILE%\Desktop\PI.lnk
contains embedded spaces when resolved, you must surround the whole lot with
double quotes:
"%ALLUSERSPROFILE%\Desktop\PI.lnk"
You must also provide the full path (share + folder name) for your source
file pi.lnk.


 
Reply With Quote
 
Pegasus \(MVP\)
Guest
Posts: n/a

 
      10-02-2008

"Linn Kubler" <> wrote in message
news:OzCi$...
> Hi,
>
> I've been asked to distribute a shortcut to a web site to all my users. I
> think the best way to do this is through the logon.bat file, however, I'm
> stuck, can't seem to figure it out. It seemed simple enough, just add the
> following code to my batch file, right?
>
> If Not Exist %ALLUSERSPROFILE%\Desktop\PI.lnk (Copy PI.lnk
> %ALLUSERSPROFILE%\Desktop)
>
> Of course this doesn't work. Can someone show me how to handle this in
> the simplest way possible? I've been Googling the solution and I'm not
> finding anything useful, just confusing.
>
> The PI.lnk file is currently located in the DC Netlogon directory.
>
> As a test I modified the line to look like this below and put a test.txt
> file on the All Users Desktop on my test system.
>
> If Not Exist %ALLUSERSPROFILE%\Desktop\test.txt (Echo "It's not there!")
> Else (Echo "It's there!")
>
> From this line I get no response in my batch file output. I'm clearly
> missing something fundamental here. Any thoughts, words of wisdom?
>
> Thanks in advance,
> Linn
>


At second thoughts: Instead of writing "if not exist . . .", use xcopy.exe
with the /d switch. This method will copy the file if it does not exist but
also if the source file is newer than the target file.


 
Reply With Quote
 
Al Dunbar
Guest
Posts: n/a

 
      10-03-2008

"Pegasus (MVP)" <> wrote in message
news:...
>
> "Linn Kubler" <> wrote in message
> news:OzCi$...
>> Hi,
>>
>> I've been asked to distribute a shortcut to a web site to all my users.
>> I think the best way to do this is through the logon.bat file, however,
>> I'm stuck, can't seem to figure it out. It seemed simple enough, just
>> add the following code to my batch file, right?
>>
>> If Not Exist %ALLUSERSPROFILE%\Desktop\PI.lnk (Copy PI.lnk
>> %ALLUSERSPROFILE%\Desktop)
>>
>> Of course this doesn't work. Can someone show me how to handle this in
>> the simplest way possible? I've been Googling the solution and I'm not
>> finding anything useful, just confusing.
>>
>> The PI.lnk file is currently located in the DC Netlogon directory.
>>
>> As a test I modified the line to look like this below and put a test.txt
>> file on the All Users Desktop on my test system.
>>
>> If Not Exist %ALLUSERSPROFILE%\Desktop\test.txt (Echo "It's not there!")
>> Else (Echo "It's there!")
>>
>> From this line I get no response in my batch file output. I'm clearly
>> missing something fundamental here. Any thoughts, words of wisdom?
>>
>> Thanks in advance,
>> Linn
>>

>
> At second thoughts: Instead of writing "if not exist . . .", use xcopy.exe
> with the /d switch. This method will copy the file if it does not exist
> but also if the source file is newer than the target file.


And finally - all of your users administrators or power users on the
workstations? If not, the script will be unable to succeed as the logon
script runs under the user's credentials.

Personally, I'd find it more straightforward to push the file out to all the
workstations while logged in to an account that is an admin on all the
workstations with something like this:

for /f %%C in (complist.txt) do (
copy PI.lnk \\%%C\c$\Documents and Settings\All Users\Desktop
)

where the complist.txt file contains a list of the computers to be updated.

/Al


 
Reply With Quote
 
Pegasus \(MVP\)
Guest
Posts: n/a

 
      10-03-2008

"Al Dunbar" <> wrote in message
news:...
>
> "Pegasus (MVP)" <> wrote in message
> news:...
>>
>> "Linn Kubler" <> wrote in message
>> news:OzCi$...
>>> Hi,
>>>
>>> I've been asked to distribute a shortcut to a web site to all my users.
>>> I think the best way to do this is through the logon.bat file, however,
>>> I'm stuck, can't seem to figure it out. It seemed simple enough, just
>>> add the following code to my batch file, right?
>>>
>>> If Not Exist %ALLUSERSPROFILE%\Desktop\PI.lnk (Copy PI.lnk
>>> %ALLUSERSPROFILE%\Desktop)
>>>
>>> Of course this doesn't work. Can someone show me how to handle this in
>>> the simplest way possible? I've been Googling the solution and I'm not
>>> finding anything useful, just confusing.
>>>
>>> The PI.lnk file is currently located in the DC Netlogon directory.
>>>
>>> As a test I modified the line to look like this below and put a test.txt
>>> file on the All Users Desktop on my test system.
>>>
>>> If Not Exist %ALLUSERSPROFILE%\Desktop\test.txt (Echo "It's not there!")
>>> Else (Echo "It's there!")
>>>
>>> From this line I get no response in my batch file output. I'm clearly
>>> missing something fundamental here. Any thoughts, words of wisdom?
>>>
>>> Thanks in advance,
>>> Linn
>>>

>>
>> At second thoughts: Instead of writing "if not exist . . .", use
>> xcopy.exe with the /d switch. This method will copy the file if it does
>> not exist but also if the source file is newer than the target file.

>
> And finally - all of your users administrators or power users on the
> workstations? If not, the script will be unable to succeed as the logon
> script runs under the user's credentials.
>
> Personally, I'd find it more straightforward to push the file out to all
> the workstations while logged in to an account that is an admin on all the
> workstations with something like this:
>
> for /f %%C in (complist.txt) do (
> copy PI.lnk \\%%C\c$\Documents and Settings\All Users\Desktop
> )
>
> where the complist.txt file contains a list of the computers to be
> updated.
>
> /Al
>


Didn't you forget a set of double-quotes there? And perhaps a /y switch in
order to avoid repeated "overwrite" prompts?


 
Reply With Quote
 
Linn Kubler
Guest
Posts: n/a

 
      10-03-2008

"Pegasus (MVP)" <> wrote in message
news:...
>
> "Al Dunbar" <> wrote in message
> news:...
>>
>> "Pegasus (MVP)" <> wrote in message
>> news:...
>>>
>>> "Linn Kubler" <> wrote in message
>>> news:OzCi$...
>>>> Hi,
>>>>
>>>> I've been asked to distribute a shortcut to a web site to all my users.
>>>> I think the best way to do this is through the logon.bat file, however,
>>>> I'm stuck, can't seem to figure it out. It seemed simple enough, just
>>>> add the following code to my batch file, right?
>>>>
>>>> If Not Exist %ALLUSERSPROFILE%\Desktop\PI.lnk (Copy PI.lnk
>>>> %ALLUSERSPROFILE%\Desktop)
>>>>
>>>> Of course this doesn't work. Can someone show me how to handle this in
>>>> the simplest way possible? I've been Googling the solution and I'm not
>>>> finding anything useful, just confusing.
>>>>
>>>> The PI.lnk file is currently located in the DC Netlogon directory.
>>>>
>>>> As a test I modified the line to look like this below and put a
>>>> test.txt file on the All Users Desktop on my test system.
>>>>
>>>> If Not Exist %ALLUSERSPROFILE%\Desktop\test.txt (Echo "It's not
>>>> there!") Else (Echo "It's there!")
>>>>
>>>> From this line I get no response in my batch file output. I'm clearly
>>>> missing something fundamental here. Any thoughts, words of wisdom?
>>>>
>>>> Thanks in advance,
>>>> Linn
>>>>
>>>
>>> At second thoughts: Instead of writing "if not exist . . .", use
>>> xcopy.exe with the /d switch. This method will copy the file if it does
>>> not exist but also if the source file is newer than the target file.

>>
>> And finally - all of your users administrators or power users on the
>> workstations? If not, the script will be unable to succeed as the logon
>> script runs under the user's credentials.
>>
>> Personally, I'd find it more straightforward to push the file out to all
>> the workstations while logged in to an account that is an admin on all
>> the workstations with something like this:
>>
>> for /f %%C in (complist.txt) do (
>> copy PI.lnk \\%%C\c$\Documents and Settings\All Users\Desktop
>> )
>>
>> where the complist.txt file contains a list of the computers to be
>> updated.
>>
>> /Al
>>

>
> Didn't you forget a set of double-quotes there? And perhaps a /y switch in
> order to avoid repeated "overwrite" prompts?


Thanks guys for the suggestions, I like this method for it's simplicity.
I've never had to do so much with batch files that I needed learned all
these tricks. Hard part here will be creating the complist.txt of computer
names and making sure they are all on.

It did occure to me last night that I don't need it in the logon script. If
I put the shortcut on the all users desktop then most users won't be able to
delete it and it should remain there. Let me give this a try.

Thanks,
Linn


 
Reply With Quote
 
Linn Kubler
Guest
Posts: n/a

 
      10-03-2008

"Pegasus (MVP)" <> wrote in message
news:...
>
> "Al Dunbar" <> wrote in message
> news:...
>>
>> "Pegasus (MVP)" <> wrote in message
>> news:...
>>>
>>> "Linn Kubler" <> wrote in message
>>> news:OzCi$...
>>>> Hi,
>>>>
>>>> I've been asked to distribute a shortcut to a web site to all my users.
>>>> I think the best way to do this is through the logon.bat file, however,
>>>> I'm stuck, can't seem to figure it out. It seemed simple enough, just
>>>> add the following code to my batch file, right?
>>>>
>>>> If Not Exist %ALLUSERSPROFILE%\Desktop\PI.lnk (Copy PI.lnk
>>>> %ALLUSERSPROFILE%\Desktop)
>>>>
>>>> Of course this doesn't work. Can someone show me how to handle this in
>>>> the simplest way possible? I've been Googling the solution and I'm not
>>>> finding anything useful, just confusing.
>>>>
>>>> The PI.lnk file is currently located in the DC Netlogon directory.
>>>>
>>>> As a test I modified the line to look like this below and put a
>>>> test.txt file on the All Users Desktop on my test system.
>>>>
>>>> If Not Exist %ALLUSERSPROFILE%\Desktop\test.txt (Echo "It's not
>>>> there!") Else (Echo "It's there!")
>>>>
>>>> From this line I get no response in my batch file output. I'm clearly
>>>> missing something fundamental here. Any thoughts, words of wisdom?
>>>>
>>>> Thanks in advance,
>>>> Linn
>>>>
>>>
>>> At second thoughts: Instead of writing "if not exist . . .", use
>>> xcopy.exe with the /d switch. This method will copy the file if it does
>>> not exist but also if the source file is newer than the target file.

>>
>> And finally - all of your users administrators or power users on the
>> workstations? If not, the script will be unable to succeed as the logon
>> script runs under the user's credentials.
>>
>> Personally, I'd find it more straightforward to push the file out to all
>> the workstations while logged in to an account that is an admin on all
>> the workstations with something like this:
>>
>> for /f %%C in (complist.txt) do (
>> copy PI.lnk \\%%C\c$\Documents and Settings\All Users\Desktop
>> )
>>
>> where the complist.txt file contains a list of the computers to be
>> updated.
>>
>> /Al
>>

>
> Didn't you forget a set of double-quotes there? And perhaps a /y switch in
> order to avoid repeated "overwrite" prompts?


Say, if I wanted to output the computer name and the result of the copy to a
log file, how would I display the computer name?

I tried adding the line; Echo %%c >> mylog.log but it just records %c.

Thanks,
Linn


 
Reply With Quote
 
Linn Kubler
Guest
Posts: n/a

 
      10-03-2008

"Linn Kubler" <> wrote in message
news:%...
>
> "Pegasus (MVP)" <> wrote in message
> news:...
>>
>> "Al Dunbar" <> wrote in message
>> news:...
>>>
>>> "Pegasus (MVP)" <> wrote in message
>>> news:...
>>>>
>>>> "Linn Kubler" <> wrote in message
>>>> news:OzCi$...
>>>>> Hi,
>>>>>
>>>>> I've been asked to distribute a shortcut to a web site to all my
>>>>> users. I think the best way to do this is through the logon.bat file,
>>>>> however, I'm stuck, can't seem to figure it out. It seemed simple
>>>>> enough, just add the following code to my batch file, right?
>>>>>
>>>>> If Not Exist %ALLUSERSPROFILE%\Desktop\PI.lnk (Copy PI.lnk
>>>>> %ALLUSERSPROFILE%\Desktop)
>>>>>
>>>>> Of course this doesn't work. Can someone show me how to handle this
>>>>> in the simplest way possible? I've been Googling the solution and I'm
>>>>> not finding anything useful, just confusing.
>>>>>
>>>>> The PI.lnk file is currently located in the DC Netlogon directory.
>>>>>
>>>>> As a test I modified the line to look like this below and put a
>>>>> test.txt file on the All Users Desktop on my test system.
>>>>>
>>>>> If Not Exist %ALLUSERSPROFILE%\Desktop\test.txt (Echo "It's not
>>>>> there!") Else (Echo "It's there!")
>>>>>
>>>>> From this line I get no response in my batch file output. I'm clearly
>>>>> missing something fundamental here. Any thoughts, words of wisdom?
>>>>>
>>>>> Thanks in advance,
>>>>> Linn
>>>>>
>>>>
>>>> At second thoughts: Instead of writing "if not exist . . .", use
>>>> xcopy.exe with the /d switch. This method will copy the file if it does
>>>> not exist but also if the source file is newer than the target file.
>>>
>>> And finally - all of your users administrators or power users on the
>>> workstations? If not, the script will be unable to succeed as the logon
>>> script runs under the user's credentials.
>>>
>>> Personally, I'd find it more straightforward to push the file out to all
>>> the workstations while logged in to an account that is an admin on all
>>> the workstations with something like this:
>>>
>>> for /f %%C in (complist.txt) do (
>>> copy PI.lnk \\%%C\c$\Documents and Settings\All Users\Desktop
>>> )
>>>
>>> where the complist.txt file contains a list of the computers to be
>>> updated.
>>>
>>> /Al
>>>

>>
>> Didn't you forget a set of double-quotes there? And perhaps a /y switch
>> in order to avoid repeated "overwrite" prompts?

>
> Say, if I wanted to output the computer name and the result of the copy to
> a log file, how would I display the computer name?
>
> I tried adding the line; Echo %%c >> mylog.log but it just records %c.
>
> Thanks,
> Linn

Oops, never mind. I just realized it's case sensitive.
Linn


 
Reply With Quote
 
Al Dunbar
Guest
Posts: n/a

 
      10-07-2008

"Pegasus (MVP)" <> wrote in message
news:...
>
> "Al Dunbar" <> wrote in message
> news:...
>>
>> "Pegasus (MVP)" <> wrote in message
>> news:...
>>>
>>> "Linn Kubler" <> wrote in message
>>> news:OzCi$...
>>>> Hi,
>>>>
>>>> I've been asked to distribute a shortcut to a web site to all my users.
>>>> I think the best way to do this is through the logon.bat file, however,
>>>> I'm stuck, can't seem to figure it out. It seemed simple enough, just
>>>> add the following code to my batch file, right?
>>>>
>>>> If Not Exist %ALLUSERSPROFILE%\Desktop\PI.lnk (Copy PI.lnk
>>>> %ALLUSERSPROFILE%\Desktop)
>>>>
>>>> Of course this doesn't work. Can someone show me how to handle this in
>>>> the simplest way possible? I've been Googling the solution and I'm not
>>>> finding anything useful, just confusing.
>>>>
>>>> The PI.lnk file is currently located in the DC Netlogon directory.
>>>>
>>>> As a test I modified the line to look like this below and put a
>>>> test.txt file on the All Users Desktop on my test system.
>>>>
>>>> If Not Exist %ALLUSERSPROFILE%\Desktop\test.txt (Echo "It's not
>>>> there!") Else (Echo "It's there!")
>>>>
>>>> From this line I get no response in my batch file output. I'm clearly
>>>> missing something fundamental here. Any thoughts, words of wisdom?
>>>>
>>>> Thanks in advance,
>>>> Linn
>>>>
>>>
>>> At second thoughts: Instead of writing "if not exist . . .", use
>>> xcopy.exe with the /d switch. This method will copy the file if it does
>>> not exist but also if the source file is newer than the target file.

>>
>> And finally - all of your users administrators or power users on the
>> workstations? If not, the script will be unable to succeed as the logon
>> script runs under the user's credentials.
>>
>> Personally, I'd find it more straightforward to push the file out to all
>> the workstations while logged in to an account that is an admin on all
>> the workstations with something like this:
>>
>> for /f %%C in (complist.txt) do (
>> copy PI.lnk \\%%C\c$\Documents and Settings\All Users\Desktop
>> )
>>
>> where the complist.txt file contains a list of the computers to be
>> updated.
>>
>> /Al
>>

>
> Didn't you forget a set of double-quotes there? And perhaps a /y switch in
> order to avoid repeated "overwrite" prompts?


I was in a hurry. But I didn't say "use this", I said that "I find it more
straightforward ... with something _LIKE_ this".

/Al


 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
shortcut on desktop - deleting the word "shortcut" snomazushi Windows Vista General Discussion 4 03-29-2009 01:54 PM
Logon Locally No Longer Appears in Logon Choices on Domain Controller VIA Remote Desktop yukon727 Windows Server 4 07-22-2008 07:43 PM
Put Shortcut into Desktop Luiz Scripting 1 12-17-2007 08:05 PM
Shortcut to desktop Uniquitous Internet Explorer 5 11-24-2006 12:55 AM
Desktop shortcut Irv Internet Explorer 1 10-23-2006 06:24 AM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59