Thanks for taking the time to read my question.
I have been searching for a solution, but have not found one online.
I have a script that copies a folder from a PC to the server. It works well on my laptop if I'm logged on as me and on the local domain. The problem I'm up against is the PC that I want to run it on will be logged on to the local machine, and not on to the domain. I tested this on my laptop and it fails when I log on to the local machine instead of on to our network.
Is there a way I can put my credentials and domain information into the script so that it can authenticate and then complete the copy?
Code:
Thanks,
Brad
I have been searching for a solution, but have not found one online.
I have a script that copies a folder from a PC to the server. It works well on my laptop if I'm logged on as me and on the local domain. The problem I'm up against is the PC that I want to run it on will be logged on to the local machine, and not on to the domain. I tested this on my laptop and it fails when I log on to the local machine instead of on to our network.
Is there a way I can put my credentials and domain information into the script so that it can authenticate and then complete the copy?
Code:
Code:
'Get the Computer Name
set shell = WScript.CreateObject( "WScript.Shell" )
computername = shell.ExpandEnvironmentStrings("%COMPUTERNAME%")
wscript.echo computername
'Make sure destination folder exists and if not make it
dim filesys, newfolder, newfolderpath
newfolderpath = "\\caws0059\site data\LSTMBackUp\" & computername & "\"
wscript.echo newfolderpath
set filesys=CreateObject("Scripting.FileSystemObject")
If Not filesys.FolderExists(newfolderpath) Then
'***Code errors out on the next line***
Set newfolder = filesys.CreateFolder(newfolderpath)
wscript.echo "A new folder has been created at: " & newfolderpath
Else
wscript.echo "It exists"
End If
'Copy Folders
dim filesys1
set filesys1=CreateObject("Scripting.FileSystemObject")
If filesys1.FolderExists("c:\P1464") Then
filesys1.CopyFolder "c:\P1464", "\\caws0059\site data\LSTMBackUp\" & computername & "\"
End If
'Confirm Copy completed
If filesys.FolderExists(newfolderpath) Then
wscript.echo "Copy compete"
Else
wscript.echo "Copy did not compete"
End If
Thanks,
Brad