Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Logon Script (Easy but im a begginner)

Posted on 2011-03-21
10
Medium Priority
?
544 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
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!

 
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 2000 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
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…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Screencast - Getting to Know the Pipeline

972 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