Solved

Logon Script (Easy but im a begginner)

Posted on 2011-03-21
10
524 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
Independent Software Vendors: 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

685 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