Solved

Logon Script (Easy but im a begginner)

Posted on 2011-03-21
10
493 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 7

Expert Comment

by:SjoerdvW
Comment Utility
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
Comment Utility
Oh - one other place that I forgot - Startup?
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 2

Expert Comment

by:khaaz
Comment Utility
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
Comment Utility

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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now