Link to home
Start Free TrialLog in
Avatar of IT CAMPER
IT CAMPERFlag for United States of America

asked on

Script to handle a few Windows tasks

I need a VB script (must be VB as I will be adding to an existing VB).  The script needs to perform the following items on a Windows  computer.

Create a folder in the current user's profile..
%userprofile%\Login Local Helpdesk

Copy files from  a UNC path to this new folder.

Create a shortcut on the user's desktop for a file that was copied above.
Avatar of RobSampson
RobSampson
Flag of Australia image

Hi, this should work for you.

Regards,

Rob.
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
strFolder = objShell.ExpandEnvironmentStrings("%UserProfile%") & "\Login Local Helpdesk\"
If objFSO.FolderExists(strFolder) = False Then
	objFSO.CreateFolder strFolder
	objFSO.CopyFile "\\server\share\*", strFolder
	strDesktop = objShell.SpecialFolders("Desktop")
	Set objShortcut = objShell.CreateShortcut(strDesktop & "\My Shortcut.lnk")
	objShortcut.TargetPath = strFolder & "RunThisFile.exe"
	objShortcut.WorkingDirectory = strFolder
	objShortcut.Save
End If

Open in new window

Avatar of IT CAMPER

ASKER

I love your solutions Rob!

Can you tweak a few things for me?  I would like for this script to also be used to repair botched executions of the script, or broken pieces of the puzzle. Currently, if I execute it and the folder already exists, it will not do anything further.  So say the user deletes the shortcut on the desktop, or a file gets deleted out of the userprofile folder.  Can you tweak the script to actually execute each command no matter pre-existing files or folders?
ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial