|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
"Linn Kubler" <lkubler@chartwellwisc2.com> wrote in message news:OzCi$GNJJHA.4280@TK2MSFTNGP04.phx.gbl... > 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. |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
"Linn Kubler" <lkubler@chartwellwisc2.com> wrote in message news:OzCi$GNJJHA.4280@TK2MSFTNGP04.phx.gbl... > 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. |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
"Pegasus (MVP)" <I.can@fly.com.oz> wrote in message news:OXfTGaNJJHA.5356@TK2MSFTNGP05.phx.gbl... > > "Linn Kubler" <lkubler@chartwellwisc2.com> wrote in message > news:OzCi$GNJJHA.4280@TK2MSFTNGP04.phx.gbl... >> 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 |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
"Al Dunbar" <AlanDrub@hotmail.com.nospaam> wrote in message news:et59ouQJJHA.740@TK2MSFTNGP03.phx.gbl... > > "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message > news:OXfTGaNJJHA.5356@TK2MSFTNGP05.phx.gbl... >> >> "Linn Kubler" <lkubler@chartwellwisc2.com> wrote in message >> news:OzCi$GNJJHA.4280@TK2MSFTNGP04.phx.gbl... >>> 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? |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
"Pegasus (MVP)" <I.can@fly.com.oz> wrote in message news:eak4FGSJJHA.4672@TK2MSFTNGP05.phx.gbl... > > "Al Dunbar" <AlanDrub@hotmail.com.nospaam> wrote in message > news:et59ouQJJHA.740@TK2MSFTNGP03.phx.gbl... >> >> "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message >> news:OXfTGaNJJHA.5356@TK2MSFTNGP05.phx.gbl... >>> >>> "Linn Kubler" <lkubler@chartwellwisc2.com> wrote in message >>> news:OzCi$GNJJHA.4280@TK2MSFTNGP04.phx.gbl... >>>> 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 |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
"Pegasus (MVP)" <I.can@fly.com.oz> wrote in message news:eak4FGSJJHA.4672@TK2MSFTNGP05.phx.gbl... > > "Al Dunbar" <AlanDrub@hotmail.com.nospaam> wrote in message > news:et59ouQJJHA.740@TK2MSFTNGP03.phx.gbl... >> >> "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message >> news:OXfTGaNJJHA.5356@TK2MSFTNGP05.phx.gbl... >>> >>> "Linn Kubler" <lkubler@chartwellwisc2.com> wrote in message >>> news:OzCi$GNJJHA.4280@TK2MSFTNGP04.phx.gbl... >>>> 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 |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
"Linn Kubler" <lkubler@chartwellwisc2.com> wrote in message news:%23OTKLoXJJHA.4996@TK2MSFTNGP03.phx.gbl... > > "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message > news:eak4FGSJJHA.4672@TK2MSFTNGP05.phx.gbl... >> >> "Al Dunbar" <AlanDrub@hotmail.com.nospaam> wrote in message >> news:et59ouQJJHA.740@TK2MSFTNGP03.phx.gbl... >>> >>> "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message >>> news:OXfTGaNJJHA.5356@TK2MSFTNGP05.phx.gbl... >>>> >>>> "Linn Kubler" <lkubler@chartwellwisc2.com> wrote in message >>>> news:OzCi$GNJJHA.4280@TK2MSFTNGP04.phx.gbl... >>>>> 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 |
|
|
|
#9 |
|
Messages: n/a
Hébergeur: |
"Pegasus (MVP)" <I.can@fly.com.oz> wrote in message news:eak4FGSJJHA.4672@TK2MSFTNGP05.phx.gbl... > > "Al Dunbar" <AlanDrub@hotmail.com.nospaam> wrote in message > news:et59ouQJJHA.740@TK2MSFTNGP03.phx.gbl... >> >> "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message >> news:OXfTGaNJJHA.5356@TK2MSFTNGP05.phx.gbl... >>> >>> "Linn Kubler" <lkubler@chartwellwisc2.com> wrote in message >>> news:OzCi$GNJJHA.4280@TK2MSFTNGP04.phx.gbl... >>>> 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 |
|
![]() |
| Outils de la discussion | |
|
|