I am borrowing a script written by Dean Flaming. (Give credit where credit is due)
This script generates a login window where the user enters a username, password and domain.
These are stored as the variables $StringUsername, $StringPassword and $StringDomain.
Near the bottom where it is trying to capture the file extension, everything looks right, but the
files don't show up in the destination directory with a file extension of any kind.
Also, the part where it is trying to map to X:\ with the USE command has an error capturing variable
that should open a messagebox telling the user they have entered the wrong password. It doesn't work
most of the time. Worked yesterday, but doesn't work today. Haven't changed anything there...
Code:
;ADD YOUR STUFF HERE SUCH AS A PRINTER OR DRIVE MAPPING, ETC.
Break On
$RC = ClearError()
Function ClearError()
Exit 0
EndFunction
If Not @USERID=$StringUsername
MessageBox ("You must be logged onto this computer with your own Username and Password.","Access is Denied")
Quit
EndIf
Use X: /Del
Select
Case InGroup ("NMDPS\D1ScheduleRead")
Use X: "\\NAS2\SPDistrict1" /User:"@Domain\$StringUsername" /Password:"$StringPassword"
Case InGroup ("NMDPS\D2SchudleRead")
Use X: "\\NAS2\SPDistrict2" /User:"@Domain\$StringUsername" /Password:"$StringPassword"
$ErrCode = @ERROR
If @ERROR <> 0
MessageBox ("You have entered an incorrect password or you are logged into the computer "+
"as someone besides yourself. Please try again.","Invalid Password")
Quit
EndIf
Case 1
MessageBox ("You do not have access to any District Folder. Please call the Helpdesk @ XXX-XXXX. "+
"Thank you.","Access is Denied") Quit
EndSelect
If Not Exist ("X:\$StringUsername")
MD "X:\$StringUsername"
EndIf
MessageBox ("Please wait while your files are copied to the Network. This may take some time. "+
"A message box will appear to inform you when this is done.","Please Wait")
Break On
$RC = ClearError()
Function ClearError()
Exit 0
EndFunction
;Call the Driplus UDF.
Call @SCRIPTDIR + "\DirPlus().udf"
;
;Enumerate all FILES on drive x:
;Change the drive to the you got in your setup.
$files = dirplus("@SCRIPTDIR\DSS_FLDA","/a-d")
;
;Split the date on the / character and the join the parts with no separation characters.
$date = Join(Split(@date, "/"),"")
;
;Get the filename without the drive letter so start counting at the 4th character.
$filename = SubStr ($file, 4)
;
;Get the extension of the file.
$ext = SubStr ($filename, Len($filename) - 4)
;
;Do the stuff inside the For each--next loop for each file found.
For Each $file in $files
;Split the time at the : character and then join the parts with no separation characters.
$time = Join(Split(@TIME, ":"),"")
;Copy the file and rename it during the copy process.
Copy $file "X:\$StringUsername\" + $date + "-" + $time + $ext
$ErrCode = @ERROR
;Sleep 1 second to get the $time var different for each file.
Sleep 1
Next
MessageBox ("Your Files have been copied to the network.","File transfer Result")
;Del "@SCRIPTDIR\DSS_FLDA\*.WMA"
Use X: /Del
;REMOVE THE FOLLOWING TEST LINE
;=======================================================================
;Exit the Script
;=======================================================================
Quit
[Long lines removed by NTDOC]