Jump to content

Need help to create bat file or vbs


Recommended Posts

Hi

I need batch file or vbs script to move,delete shortcut.lnk and folder to difrent place

move all shortcut from desktop form curent user and allusers to Shortcut folder on desktop

and need delete some shortcut from desktop

and i want custumize AllPrograms

example:

create Security folder on All Users\Start Menu\Programs

and then move Kaspersky Anti-Virus 6.0 shortcut form Kaspersky Anti-Virus 6.0 folder from

\All Users\Start Menu\Programs

and then delete Kaspersky Anti-Virus 6.0 folder form \All Users\Start Menu\Programs

Edit:at RunOnceEx

Edited by hessam
Link to comment
Share on other sites


Here's some base code to work off of for a batch file:

@echo off
title Link Customizer
mkdir "%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>&1

The 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

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

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

thanks to Idontwantspamits for help me really good toutrial for me

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

Del "%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 off
title Link Customizer
mkdir "%userprofile%\desktop\CleanUp" > NUL 2>&1
move "%allusersprofile%\desktop\Office Slipstreamer.lnk" "%userprofile%\desktop\CleanUp\Office Slipstreamer.lnk" > NUL 2>&1
move "%allusersprofile%\desktop\Quick Mail.lnk" "%userprofile%\desktop\CleanUp\Quick Mail.lnk" > NUL 2>&1
move "%userprofile%\desktop\Opera.lnk" "%userprofile%\desktop\CleanUp\Opera.lnk" > NUL 2>&1
move "%userprofile%\desktop\MagicDisc.lnk" "%userprofile%\desktop\CleanUp\MagicDisc.lnk" > NUL 2>&1
move "%allusersprofile%\desktop\Vista Rainbar.lnk" "%userprofile%\desktop\CleanUp\Vista Rainbar.lnk" > NUL 2>&1
move "%userprofile%\desktop\Shock Aero 3D.LNK" "%userprofile%\desktop\CleanUp\Shock Aero 3D.LNK" > NUL 2>&1
move "%userprofile%\desktop\nLite.lnk" "%userprofile%\desktop\CleanUp\nLite.lnk" > NUL 2>&1
move "%allusersprofile%\desktop\PC Security.lnk" "%userprofile%\desktop\CleanUp\PC Security.lnk" > NUL 2>&1
mkdir "%userprofile%\start menu\programs\securities" > NUL 2>&1
move "%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

You don't use del to remove a directory, you use RD or RMDIR

The command you therefore need is:

@Echo off&Setlocal enableextensions
Title Link Customizer
If Not Exist %UserProfile%\Desktop\CleanUp^
Md %UserProfile%\Desktop\CleanUp 2>Nul
Pushd %UserProfile%\Desktop\CleanUp||Goto SMP
If Exist "%AllUsersProfile%\Desktop\Office Slipstreamer.lnk"^
Move "%AllUsersProfile%\Desktop\Office Slipstreamer.lnk">Nul
If Exist "%AllUsersProfile%\Desktop\Quick Mail.lnk"^
Move "%AllUsersProfile%\Desktop\Quick Mail.lnk">Nul
If Exist "%AllUsersProfile%\Desktop\Vista Rainbar.lnk"^
Move "%AllUsersProfile%\Desktop\Vista Rainbar.lnk">Nul
If Exist "%AllUsersProfile%\Desktop\PC Security.lnk"^
Move "%AllUsersProfile%\Desktop\PC Security.lnk">Nul
If Exist ..\Opera.lnk Move ..\Opera.lnk>Nul
If Exist ..\MagicDisc.ln Move ..\MagicDisc.lnk>Nul
If Exist "..\Shock Aero 3D.lnk" Move "..\Shock Aero 3D.lnk">Nul
If Exist ..\nLite.lnk Move ..\nLite.lnk>Nul
:SMP
Set "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

  • 3 months later...

Hey All

I 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 off

start /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 desktop

move "%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 /s

exit

thanks in advance

Rexxar

Link to comment
Share on other sites

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

You may also have trouble because your image is a .jpg as opposed to .bmp.

Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...