Solved

Logon Script (Easy but im a begginner)

Posted on 2011-03-21
10
514 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
  • 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
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
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

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

809 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