hessam Posted January 24, 2009 Share Posted January 24, 2009 (edited) Hi I need batch file or vbs script to move,delete shortcut.lnk and folder to difrent placemove all shortcut from desktop form curent user and allusers to Shortcut folder on desktopand need delete some shortcut from desktopand i want custumize AllPrograms example:create Security folder on All Users\Start Menu\Programsand then move Kaspersky Anti-Virus 6.0 shortcut form Kaspersky Anti-Virus 6.0 folder from \All Users\Start Menu\Programsand then delete Kaspersky Anti-Virus 6.0 folder form \All Users\Start Menu\ProgramsEdit:at RunOnceEx Edited January 24, 2009 by hessam Link to comment Share on other sites More sharing options...
Idontwantspam Posted January 25, 2009 Share Posted January 25, 2009 Here's some base code to work off of for a batch file: @echo offtitle Link Customizermkdir "%userprofile%\desktop\folder" (this makes a new folder on the user's desktop)move "%userprofile%\desktop\linkname.lnk" "%userprofile%\desktop\folder\linkname.lnk" (this moves the link from the desktop to the new folder) mkdir "%userprofile%\start menu\programs\securities" (makes a new folder called "securities" on the start menu) move "%userprofile%\start menu\programs\kaspersky\program.lnk" "%userprofile%\start menu\programs\securities\program.lnk" (moves the kaspersky link to the securities folder)You'll have to mess around and see what works for you. %userprofile% goes to the current user's profile, which is usually C:\documents and settings\username, but by typing %userprofile% it'll work regardless of the username or the folder it happens to be. You can sub %allusersprofile% in any of the above examples for it to do C:\documents and settings\all users instead. Also, if you don't want the batch file to say "Operation Completed Successfully" after each move, you can add > NUL 2>&1 to the end of any line of code. For example, move "%userprofile%\desktop\linkname.lnk" "%userprofile%\desktop\folder\linkname.lnk" > NUL 2>&1The only problem with this is that if there's an error, it won't display the error either. You could put just > NUL instead to have it display error output but not normal output. Basically you want to use the MOVE command, which is pretty simple move "location 1" "location 2"Hope that helps! Link to comment Share on other sites More sharing options...
Yzöwl Posted January 25, 2009 Share Posted January 25, 2009 I'd just like to add that only you know the exact names and locations of your shortcuts and which you need to move or delete; so unless we have an identical setup or access to your shortcut listing and full instructions we cannot help you much more than Idontwantspam's response above. Link to comment Share on other sites More sharing options...
gunsmokingman Posted January 25, 2009 Share Posted January 25, 2009 This VBS script is for the shortcuts only, I have tested this on Win7 and it works.Save As CleanUpShortCuts.vbs Dim Act :Set Act = CreateObject("Wscript.Shell") Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") Dim AllUserDT, Folder, Obj, ScFolder, UserDtop'-> Paths For Script UserDtop = Act.SpecialFolders("Desktop") AllUserDT = Act.SpecialFolders("AllUsersDesktop") ScFolder = UserDtop & "\Folder"'-> Start The Function ShortCutCleanUp() Function ShortCutCleanUp() '-> All Users Desktop If Not Fso.FolderExists(ScFolder) Then Fso.CreateFolder(ScFolder) Set Folder = Fso.GetFolder(AllUserDT) CollectLnk() '-> User Desktop Set Folder = Fso.GetFolder(UserDtop) CollectLnk() End Function'-> Collect The Shortcuts Function CollectLnk() For Each Obj In Folder.Files If Right(InStr(LCase(Obj.Path),lcase(".lnk")),4) Then Fso.CopyFile Obj.Path, ScFolder & "\" & Obj.Name, True WScript.Sleep (100) Fso.DeleteFile(Obj.Path) End If Next End Function Link to comment Share on other sites More sharing options...
hessam Posted January 25, 2009 Author Share Posted January 25, 2009 thanks to Idontwantspamits for help me really good toutrial for methis my bat file all thing good worked but when move kaspersky shortcut to %userprofile%\start menu\programs\securities i want Delete "Kaspersky Anti-Virus 6.0" FOLDER FROM %allusersprofile%\start menu\programs\Kaspersky Anti-Virus 6.0 I Using thisDel "%allusersprofile%\start menu\programs\Kaspersky Anti-Virus 6.0"but this dont delete folder this only delte other shortcut into Kaspersky Anti-Virus 6.0 folder@echo offtitle Link Customizermkdir "%userprofile%\desktop\CleanUp" > NUL 2>&1move "%allusersprofile%\desktop\Office Slipstreamer.lnk" "%userprofile%\desktop\CleanUp\Office Slipstreamer.lnk" > NUL 2>&1move "%allusersprofile%\desktop\Quick Mail.lnk" "%userprofile%\desktop\CleanUp\Quick Mail.lnk" > NUL 2>&1move "%userprofile%\desktop\Opera.lnk" "%userprofile%\desktop\CleanUp\Opera.lnk" > NUL 2>&1move "%userprofile%\desktop\MagicDisc.lnk" "%userprofile%\desktop\CleanUp\MagicDisc.lnk" > NUL 2>&1move "%allusersprofile%\desktop\Vista Rainbar.lnk" "%userprofile%\desktop\CleanUp\Vista Rainbar.lnk" > NUL 2>&1move "%userprofile%\desktop\Shock Aero 3D.LNK" "%userprofile%\desktop\CleanUp\Shock Aero 3D.LNK" > NUL 2>&1move "%userprofile%\desktop\nLite.lnk" "%userprofile%\desktop\CleanUp\nLite.lnk" > NUL 2>&1move "%allusersprofile%\desktop\PC Security.lnk" "%userprofile%\desktop\CleanUp\PC Security.lnk" > NUL 2>&1mkdir "%userprofile%\start menu\programs\securities" > NUL 2>&1move "%allusersprofile%\start menu\programs\Kaspersky Anti-Virus 6.0\Kaspersky Anti-Virus 6.0.lnk" "%userprofile%\start menu\programs\securities\Kaspersky Anti-Virus 6.0.lnk" > NUL 2>&1"to gunsmokingman your script working in xp its very easy and fast thanks to help me Link to comment Share on other sites More sharing options...
Yzöwl Posted January 26, 2009 Share Posted January 26, 2009 You don't use del to remove a directory, you use RD or RMDIRThe command you therefore need is:@Echo off&Setlocal enableextensionsTitle Link CustomizerIf Not Exist %UserProfile%\Desktop\CleanUp^ Md %UserProfile%\Desktop\CleanUp 2>NulPushd %UserProfile%\Desktop\CleanUp||Goto SMPIf Exist "%AllUsersProfile%\Desktop\Office Slipstreamer.lnk"^ Move "%AllUsersProfile%\Desktop\Office Slipstreamer.lnk">NulIf Exist "%AllUsersProfile%\Desktop\Quick Mail.lnk"^ Move "%AllUsersProfile%\Desktop\Quick Mail.lnk">NulIf Exist "%AllUsersProfile%\Desktop\Vista Rainbar.lnk"^ Move "%AllUsersProfile%\Desktop\Vista Rainbar.lnk">NulIf Exist "%AllUsersProfile%\Desktop\PC Security.lnk"^ Move "%AllUsersProfile%\Desktop\PC Security.lnk">NulIf Exist ..\Opera.lnk Move ..\Opera.lnk>NulIf Exist ..\MagicDisc.ln Move ..\MagicDisc.lnk>NulIf Exist "..\Shock Aero 3D.lnk" Move "..\Shock Aero 3D.lnk">NulIf Exist ..\nLite.lnk Move ..\nLite.lnk>Nul:SMPSet "SMP=Start Menu Programs"Set "KAV=Kaspersky Anti-Virus 6.0"If Not Exist "%UserProfile%\%SMP%\Securities" ( Md "%UserProfile%\%SMP%\Securities" 2>Nul||Goto :Eof)If Exist "%UserProfile%\%SMP%\Securities" ( If Exist "%AllUsersProfile%\%SMP%\%KAV%\%KAV%.lnk" ( Move "%AllUsersProfile%\%SMP%\%KAV%\%KAV%.lnk"^ "%UserProfile%\%SMP%\Securities">Nul&&( RD/s/q "%AllUsersProfile%\%SMP%\%KAV%"))) Link to comment Share on other sites More sharing options...
hessam Posted January 26, 2009 Author Share Posted January 26, 2009 thanks Yzöwl for helping me its working again thanks Link to comment Share on other sites More sharing options...
Rexxar Posted May 3, 2009 Share Posted May 3, 2009 Hey AllI Would like to add a line that makes a jpg file that has been put in a folder "Rexxar" on the desktop a wallpaper.here is what i have so far @echo offstart /wait %systemdrive%\install\Firefox.msi /quiet <irrelevant>start /wait %systemdrive%\install\Profiles.exe /s <irrelevant>start /wait %Systemdrive%\install\Regtweaks.reg /s <irrelevant>mkdir "%userprofile%\desktop\Rexxar" <makes to folder on desktopmove "%systemdrive%\install\Rexxar" "%userprofile%\desktop\Rexxar" <copies the folder with my files to the desktop (a file named wally1.jpg is in this folder, and that needs to be the wallpaper)RD %systemdrive%\install /q /sexitthanks in advanceRexxar Link to comment Share on other sites More sharing options...
Yzöwl Posted May 3, 2009 Share Posted May 3, 2009 You don't need to create a directory first, if you are using move just do this!move "%systemdrive%\install\Rexxar" "%userprofile%\desktop"To set the wallpaper you'd need to use a specialist utility such as Set Wallpaper v1.10 (SetWallpaper.zip) Last Updated: 11/21/2000You may also have trouble because your image is a .jpg as opposed to .bmp. Link to comment Share on other sites More sharing options...
gunsmokingman Posted May 4, 2009 Share Posted May 4, 2009 You could use this VBS script to change the wallpaper. I have only tested this on Vista Sp2 and it works.You will have to fill out the path to your WallPaper.Save As ChangeWallPaper.vbs Dim Act :Set Act = CreateObject("Wscript.Shell") Dim WD :WD= Act.ExpandEnvironmentStrings("%SYSTEMROOT%") Dim WallPaper :WallPaper = WD & "\Web\Wallpaper\img17.jpg" Dim Rundll :Rundll = WD & "\System32\rundll32.exe" Act.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", WallPaper Act.Run (Rundll & " user32.dll,UpdatePerUserSystemParameters"), 1, True Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now