not a vbscript guy....(wish i was)
iam trying to make a backup script.ive managed with a lot of reading online to create this.my nas createw a folder of the user that is logging on
' ----------------------------------------------------------------------'
Option Explicit
Dim objNetwork, objShell, objFolder, objFile
Dim objFso, alreadyConnect, strTargetFolder, strFileToMove
Dim strDriveLetter, strRemotePath, strUser, strPassword, strProfile, strUsr, strPwd
'Values of variables set
WScript.Echo "Please close any files or program you have open"
strDriveLetter = "P:"
strUsr = InputBox("Please Enter Your Authenticated Username")
strPwd = InputBox("Please enter your Authenticated Password:")
strRemotePath = "\\remote server\" & strUsr
strProfile = "false"
'This section creates a network object
'Then apply MapNetworkDrive . Result P: drive
Set objNetwork = WScript.CreateObject("WScript.Network")
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath, _
strProfile, strUsr, strPwd
'add a message box
WScript.Echo " Map drive letter: "& strDriveLetter
WScript.Echo "Please wait until 'finish copying files' message appears"
This is to show the progress bar(found it on internet)
strTargetFolder = "\\remote server\" & strUsr
If Right(strTargetFolder, 1) <> "\" Then strTargetFolder = strTargetFolder & "\"
Const FOF_CREATEPROGRESSDLG = &H10&
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace(strTargetFolder)
strFileToMove = "C:\test"
Set objFile = objFSO.GetFolder(strFileToMove)
If Not objFolder Is Nothing Then
objFolder.CopyHere objFile.Path, FOF_CREATEPROGRESSDLG
Else
MsgBox "There was an error finding " & strTargetFolder
End If
if all are ok
WScript.Echo "finish copying files"
'disconnect map drive
If strDriveLetter = "P:" then
objNetwork.RemoveNetworkDrive "P:" 'here i get the error that there are still open files, and all are stopped
Else
End if
WScript.Quit
iam trying to make a backup script.ive managed with a lot of reading online to create this.my nas createw a folder of the user that is logging on
' ----------------------------------------------------------------------'
Option Explicit
Dim objNetwork, objShell, objFolder, objFile
Dim objFso, alreadyConnect, strTargetFolder, strFileToMove
Dim strDriveLetter, strRemotePath, strUser, strPassword, strProfile, strUsr, strPwd
'Values of variables set
WScript.Echo "Please close any files or program you have open"
strDriveLetter = "P:"
strUsr = InputBox("Please Enter Your Authenticated Username")
strPwd = InputBox("Please enter your Authenticated Password:")
strRemotePath = "\\remote server\" & strUsr
strProfile = "false"
'This section creates a network object
'Then apply MapNetworkDrive . Result P: drive
Set objNetwork = WScript.CreateObject("WScript.Network")
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath, _
strProfile, strUsr, strPwd
'add a message box
WScript.Echo " Map drive letter: "& strDriveLetter
WScript.Echo "Please wait until 'finish copying files' message appears"
This is to show the progress bar(found it on internet)
strTargetFolder = "\\remote server\" & strUsr
If Right(strTargetFolder, 1) <> "\" Then strTargetFolder = strTargetFolder & "\"
Const FOF_CREATEPROGRESSDLG = &H10&
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace(strTargetFolder)
strFileToMove = "C:\test"
Set objFile = objFSO.GetFolder(strFileToMove)
If Not objFolder Is Nothing Then
objFolder.CopyHere objFile.Path, FOF_CREATEPROGRESSDLG
Else
MsgBox "There was an error finding " & strTargetFolder
End If
if all are ok
WScript.Echo "finish copying files"
'disconnect map drive
If strDriveLetter = "P:" then
objNetwork.RemoveNetworkDrive "P:" 'here i get the error that there are still open files, and all are stopped
Else
End if
WScript.Quit