Solved

Logon Script (Easy but im a begginner)

Posted on 2011-03-21
10
540 Views
Last Modified: 2012-06-27
I want to write a batch file to replace some files on network pc's

first it needs to detect if the following directory exists "C:\1stDir32\" and if it does then replace the file called AOTB.lnk on the desktop and in the start menu with - "\\server\LHS Install Set\VirtualCabinetSelector\AOTB.lnk"

I Also need to take into accoun t weather the PC is XP or Windows7

Can anybody help? I am no good at VBScript :o(
0
Comment
Question by:ict-torquilclark
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
10 Comments
 
LVL 2

Expert Comment

by:khaaz
ID: 35180385
simple cmd version you could change the stat menu target path, I don't know in wich programs subfolder your shortcut is :

cd /D c:\1stDri32
IF %errorlevel%==1 goto fin

xcopy "\\server\LHS Install Set\VirtualCabinetSelector\AOTB.lnk" "%userprofile%\desktop\AOTB.lnk" /Y
xcopy "\\server\LHS Install Set\VirtualCabinetSelector\AOTB.lnk" "%userprofile%\start menu\programs\AOTB.lnk" /Y

:fin

Open in new window


tell me If you really want a vbscript version
0
 
LVL 1

Author Comment

by:ict-torquilclark
ID: 35180439
No

Thats great - just one added thing - this link may also be in the All Users desktop and start menu?
0
 
LVL 7

Expert Comment

by:SjoerdvW
ID: 35180501
Havent tested it, but this script should do the job (on both XP & Win7)
Set objShell = WScript.CreateObject("WScript.Shell")
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
If (objFSO.FolderExists("C:\1stDir32\")) Then
  objFSO.CopyFile "\\server\LHS Install Set\VirtualCabinetSelector\AOTB.lnk", objShell.SpecialFolders("Desktop"), True 
  objFSO.CopyFile "\\server\LHS Install Set\VirtualCabinetSelector\AOTB.lnk", objShell.SpecialFolders("StartMenu"), True 
End If

Open in new window

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Expert Comment

by:SjoerdvW
ID: 35180516
And also replace in the all user desktop & all user startmenu
Set objShell = WScript.CreateObject("WScript.Shell")
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
If (objFSO.FolderExists("C:\1stDir32\")) Then
  objFSO.CopyFile "\\server\LHS Install Set\VirtualCabinetSelector\AOTB.lnk", objShell.SpecialFolders("Desktop"), True 
  objFSO.CopyFile "\\server\LHS Install Set\VirtualCabinetSelector\AOTB.lnk", objShell.SpecialFolders("StartMenu"), True 
  objFSO.CopyFile "\\server\LHS Install Set\VirtualCabinetSelector\AOTB.lnk", objShell.SpecialFolders("AllUserDesktop"), True 
  objFSO.CopyFile "\\server\LHS Install Set\VirtualCabinetSelector\AOTB.lnk", objShell.SpecialFolders("AllUserStartMenu"), True 
End If

Open in new window

0
 
LVL 1

Author Comment

by:ict-torquilclark
ID: 35180593
Oh - one other place that I forgot - Startup?
0
 
LVL 2

Expert Comment

by:khaaz
ID: 35180633
with all users desktop and start menu and startup

cd /D c:\1stDri32
IF %errorlevel%==1 goto fin

xcopy "\\server\LHS Install Set\VirtualCabinetSelector\AOTB.lnk" "%userprofile%\desktop\AOTB.lnk" /Y
xcopy "\\server\LHS Install Set\VirtualCabinetSelector\AOTB.lnk" "%userprofile%\start menu\programs\AOTB.lnk" /Y
xcopy "\\server\LHS Install Set\VirtualCabinetSelector\AOTB.lnk" "%userprofile%\start menu\programs\startup\AOTB.lnk" /Y

xcopy "\\server\LHS Install Set\VirtualCabinetSelector\AOTB.lnk" "%allusersprofile%\start menu\programs\AOTB.lnk" /Y
xcopy "\\server\LHS Install Set\VirtualCabinetSelector\AOTB.lnk" "%allusersprofile%\desktop\AOTB.lnk" /Y
xcopy "\\server\LHS Install Set\VirtualCabinetSelector\AOTB.lnk" "%allusersprofile%\start menu\programs\startup\AOTB.lnk" /Y



:fin 

Open in new window

0
 
LVL 7

Expert Comment

by:SjoerdvW
ID: 35180636

objFSO.CopyFile "\\server\LHS Install Set\VirtualCabinetSelector\AOTB.lnk", objShell.SpecialFolders("Startup"), True 
  objFSO.CopyFile "\\server\LHS Install Set\VirtualCabinetSelector\AOTB.lnk", objShell.SpecialFolders("AllUsersStartup"), True

Open in new window

0
 
LVL 7

Expert Comment

by:SjoerdvW
ID: 35180687
The cmd version should check the windows version. For windows 7 the Startmenu is in  "%userprofile%\AppData\Roaming\Microsoft\Windows\Start Menu"
0
 
LVL 1

Author Comment

by:ict-torquilclark
ID: 35187827
OK

I have gone with the CMD version as I will just be able to add it to our existing logon script

I have tried runnig it manually but i am getting

does %userprofile%\desktop\AOTB.lnk specify a filename or the directory? F=filename D=directory

any ideas?
0
 
LVL 2

Accepted Solution

by:
khaaz earned 500 total points
ID: 35187862
it is not necessary to specify the destination file name :

cd /D c:\1stDri32
IF %errorlevel%==1 goto fin

xcopy "\\server\LHS Install Set\VirtualCabinetSelector\AOTB.lnk" "%userprofile%\desktop\" /Y
xcopy "\\server\LHS Install Set\VirtualCabinetSelector\AOTB.lnk" "%userprofile%\start menu\programs\" /Y
xcopy "\\server\LHS Install Set\VirtualCabinetSelector\AOTB.lnk" "%userprofile%\start menu\programs\startup\" /Y

xcopy "\\server\LHS Install Set\VirtualCabinetSelector\AOTB.lnk" "%allusersprofile%\start menu\programs\" /Y
xcopy "\\server\LHS Install Set\VirtualCabinetSelector\AOTB.lnk" "%allusersprofile%\desktop\" /Y
xcopy "\\server\LHS Install Set\VirtualCabinetSelector\AOTB.lnk" "%allusersprofile%\start menu\programs\startup\" /Y



:fin  

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question