VB script

crisp82

Golden Member
Apr 8, 2002
1,920
0
0
Hi,

I need to create a script that will do the following using the %USERNAME% variable:


Create a folder called HTML Signatures in a mapped drive (Z:)

Copy a file from a UNC share to a mapped drive on the local computer (Z:)

Copy that same file to the root of the C: (the logged on user has no permissions to this)



My thought was to create a VB script that did the following:


Get username

Cache username

Check if folder HTML Signatures exists (Z:\HTML Signatures)

Create folder if not, skip if it does

Copy file from UNC (\\servename\share\%USERNAME\file) to Z:

Copy file from UNC to C: - run as admin credentials prompted for.


I have no idea how to code this though....Help!


Thanks in advance,


Chris
 

KB

Diamond Member
Nov 8, 1999
5,406
389
126
Learning scripting is a rewarding experience. You can probably search for code by task and find code pretty easily. MSDN also has a lot of sample scripts and documentation:
http://msdn.microsoft.com/en-us/library/ms950396.aspx


I will get you started:

'Get Username

Set objNetwork = CreateObject("Wscript.Network")
Username = objNetwork.UserName

'Check if folder exists
dim filesys, newfolder
set filesys=CreateObject("Scripting.FileSystemObject")
If Not filesys.FolderExists("Z:\HTML Signatures") Then
newfolder = filesys.CreateFolder ("Z:\HTML Signatures")
End If