OK. After several days of tweaking I finally have the script running the way I would like. (Almost) There are a few remaining isuues that I need to work out and I was hoping someone out there has a suggestion. My book for Kix script editing by Bob Kelly came in, but our admin secretary went to pick it up and never came back. She gave notice and has been calling in sick every day since. Might need to reorder...

What I really need is to find a way to verify that my files have actually been copied to the network share before allowing the script to delete them from the USB storage device. I have to do a copy so that the new files show up with the current day's creation date. The recorders lose their time settings frequently and then the time\date resets to factory default. This messes me all up since I MUST retain these files for 90 days. No more. No less. When files created today are showing up with creation dates of 2 years ago it really causes problems. We are required by law to retain these recording for 90 days, and if my script fails to copy them, then deletes them from the recorder, then I might find myself in front of a judge explaining why I deleted them. Ouch. Not gonna happen. I put a statement after the file copy command that uses If @result. And that does sort of work. But I think this is only checking the result of the very last file copied. If the first 5 fail, and then the last one succeeds, then the script will not notify the end user in anyway, and will proceed to delete the files from the device. Bad. Don't know what to do with it.
Code:
 
For Each $File in $Files
If $File
;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 + '.WMA'
;Sleep 1 second to get the $Time var different for each file.
Sleep 1
EndIf
Next
$result = @RESULT
If $result = '1 file(s) copied.'
$Msg = MessageBox ('Your Files have been succesfully copied to the ' +
'network.','File transfer Result')
Else $Msg = MessageBox ('An Error has occurred during the file transfer process. ' +
'Your files are still on the recorder. Please Call the Helpdesk.','Error')
EndIf


Here is the entirety of my script as it now reads: I know it is kind of long, but several people have asked for the entire script. Thanks in advance for any assistance. By the way, is there a way to automatically change the script so it fits in the window? I read about the "print thread" link but I don't see it here?

Code:
  ;region Script Settings
;<settings><scriptpackager><process>kix32.exe</process>
;<arguments></arguments>
;<extractdir>%TEMP%</extractdir>
;<outputdir>C:\Documents and Settings\dgraham\Desktop</outputdir>
;<files></files>
;<usedefaulticon>True</usedefaulticon>
;<icon></icon>
;<showinsystray>True</showinsystray>
;<tooltip></tooltip>
;<altcreds>False</altcreds>
;<efs>True</efs>
;<ntfs>True</ntfs>
;<local>False</local>
;<username></username>
;<domain></domain>
;<abortonfail>True</abortonfail>
;<product></product>
;<internalname></internalname>
;<version>1.0.0.1</version>
;<versionstring></versionstring>
;<description></description>
;<comments></comments>
;<company></company>
;</scriptpackager>
;</settings>
;
;endregion

;===============================================================================================
;Written in AdminScriptEditor Ver 2
;Dean Flaming
;Sr. Systems Engineer
;MTM Technologies
;425-481-8181 (Seattle Office - Home Office)
;DFlaming@mtm.com
;http://www.mtm.com
;===========================
;Author Variable Information
;===========================
$Author = "Dean Flaming - Sr. Systems Engineer - MTM Technologies"
$Date = "Last Modified on 6/28/2005"
;======================================================================
;This script is designed to create a login box for a user to type in
;their username, password, and domain. It then returns these three
;values as variables that the rest of the script(s) can use.
;
;To use this script, remove the "$Test = MessageBox" line around lines
;90-100 and add whatever you need (i.e. USE statement or whatever)
;after the ENDFUNCTION line.
;
;You no longer need to have KIXFORMS.DLL installed and registered unless
;you wish to run this script from inside the KIXSCRIPTS editor or directly
;against the KIX engine.
;
;To obtain the latest copy of KIXFORMS.DLL go to http://www.kixforms.com
;and select DOWNLOADS. Copies of KIXTART and KIXTART Help files can be
;found here as well.
;======================================================================
;===============================================================================================

;======================================================================
;Variables
;======================================================================
$ = SetConsole("Hide")

;Generic Variables
Global $Nul,$Test

;KixForms Variables
Global $WindowsKey,$WindowsValue,$SystemFolder,$WindowsFolder,$NewKixFormsFile,$KixFormsRegistered,
$KixFormsCopied,$KixFormsKey1,$KixFormsKey2,$KixFormsVer1,$KixFormsVer2,$CurrentKixFormsFile,
$KixFormsKeyName1,$KixFormsKeyName2,$KixFormsExist1,$KixFormsExist2

;Login Box Variables
Global $StringUsername,$StringPassword,$StringDomain


;=======================================================================
;Check for and Install KIXFORMS if necessary for use with this script
;=======================================================================
$Nul = CheckKiXFormsDLL ;Copy in KIXFORMS.DLL and Register it

$Nul = ReadInWorkingFolder ;Read in path of ScriptFolder


;=======================================================================
;Call the Login Box
;=======================================================================
$Nul = LoginWindow


;ADD YOUR STUFF HERE SUCH AS A PRINTER OR DRIVE MAPPING, ETC.
Break On
;Dim $SO
;$SO=SetOption('Explicit','On')
;$SO=SetOption('NoVarsInStrings','On')
;$SO=SetOption('NoMacrosInStrings','On')

Dim $Msg,$RC
Dim $Files,$Date,$Filename,$Ext,$Time

If Not @USERID=$StringUsername
$Msg = MessageBox ('You must be logged onto this computer with your own Username '+
'and Password.','Access is Denied')
Quit 5 ;Set ERROR LEVEL to 5 for Access Denied
EndIf

Use X: /Del /Persistent
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
;Not 100% certain about the /Password:$StringPassword but don't think it
;would like a + sign being used there
$ErrCode = @ERROR
If $ErrCode <> 0
$Msg = MessageBox ('Error.','Error')
Quit 5 ;Set ERROR LEVEL to 5 for Access Denied
EndIf
Case 1
$Msg = MessageBox ('You do not have access to any District Folder. Please call the Helpdesk ' +
'@ XXX-XXXX. Thank you.','Access is Denied')
Quit 5 ;Set ERROR LEVEL to 5 for Access Denied
EndSelect

If GetFileAttr('X:\'+$StringUsername) & 16
Else
MD 'X:\'+$StringUsername
EndIf

$Msg = 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')

;Call the Driplus UDF.
Call @SCRIPTDIR + "\DirPlus.udf"
;
;Enumerate all FILES on drive x:
$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
If $File
;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 + '.WMA'
;Sleep 1 second to get the $Time var different for each file.
Sleep 1
EndIf
Next
$result = @RESULT
If $result = '1 file(s) copied.'
$Msg = MessageBox ('Your Files have been succesfully copied to the ' +
'network.','File transfer Result')
Else $Msg = MessageBox ('An Error has occurred during the file transfer process. ' +
'Your files are still on the recorder. Please Call the Helpdesk.','Error')
EndIf
Use X: /Del /Persistent
;Del @SCRIPTDIR+'\DSS_FLDA\*.WMA'


;=======================================================================
;Exit the Script
;=======================================================================
Quit


;=======================================================================
;Subfunctions and Routines
;=======================================================================
;========================================
;Read in path of ScriptFolder
;========================================
Function ReadInWorkingFolder
If Exist("@SCRIPTDIR\kixtartmsgs.dll")
$WorkingFolder = "@SCRIPTDIR"
Else
$WorkingFolder = $EXEPath
EndIf
EndFunction


;========================================
;Check for and Install KIXFORMS if
;necessary for use with this script
;========================================
Function CheckKiXFormsDLL
;Dim $NewKixFormsFile,$KixFormsRegistered,$KixFormsCopied,
$KixFormsKey1,$KixFormsKey2,$KixFormsVer1
;Dim $KixFormsVer2,$CurrentKixFormsFile,$KixFormsKeyName1,
$KixFormsKeyName2,$KixFormsExist1,$KixFormsExist2
;========================================
;Read in path of new KIXFORMS.DLL file
;========================================
If Exist("@SCRIPTDIR\KIXFORMS.DLL")
$NewKixFormsFile = "@SCRIPTDIR\KIXFORMS.DLL"
Else
$NewKixFormsFile = "$EXEPath\KIXFORMS.DLL"
EndIf

;========================================
;Set Variables for KIXFORMS registration and copy
;========================================
$KixFormsRegistered = 0
$KixFormsCopied = 0

;========================================
;Determine Operating System (Win 9x or NT
;based) AND Windows AND System folders.
;For support of script
;========================================
;Dim $WindowsKey,$WindowsValue,$SystemFolder,$WindowsFolder
If "@INWIN" = "2"
$WindowsKey = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\"
$WindowsValue = "SystemRoot"
$SystemFolder = "System"
Else
$WindowsKey = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\"
$WindowsValue = "SystemRoot"
$SystemFolder = "System32"
EndIf

$WindowsFolder = ReadValue("$WindowsKey","$WindowsValue")

;========================================
;Lookup KIXFORMS.DLL Class IDs to
;determine if it is already registered
;For support of script
;========================================
$KixFormsKey1 = "HKEY_CLASSES_ROOT\CLSID\{F89DF848-618A-46F9-8A1C-396EA442BDD3}\InprocServer32\"
$KixFormsKey2 = "HKEY_CLASSES_ROOT\TypeLib\{C8DCCD39-471D-4AFD-8EA2-89604A9C6252}\1.0\0\win32\"

;========================================
;Read in path of existing KIXFORMS.DLL file
;For support of script
;========================================
$CurrentKixFormsFile = ReadValue("$KixFormsKey1","")
;========================================
;Get File Versions of both new and
;existing KIXFORMS.DLL files
;For support of script
;========================================
$KixFormsVer1 = GetFileVersion("$NewKixFormsFile")
$KixFormsVer2 = GetFileVersion("$CurrentKixFormsFile")
;========================================
;Check if Current KixForms File Really
;Exists and set to value if necessary
;For support of script
;========================================
If $CurrentKixFormsFile = ""
$CurrentKixFormsFile = $WindowsFolder + "\System32\KixForms.DLL"
EndIf

;========================================
;Compare version numbers of new and
;existing KIXFORMS.DLL files
;For support of script
;========================================
If (($KixFormsVer1 > $KixFormsVer2) Or ($KixFormsVer2 = ""))
Copy "$NewKixFormsFile" "$CurrentKixFormsFile" /H
$KixFormsCopied = 1 ;Set the copy value
EndIf

;========================================
;If KIXFORMS.DLL not registered,
;register the DLL
;For support of script
;========================================
$KixFormsKeyName1 = ReadValue("$KixFormsKey1","") ;Read in Key 1
$KixFormsKeyName2 = ReadValue("$KixFormsKey2","") ;Read in Key 2
$KixFormsExist1 = UCase(SubStr("$KixFormsKeyName1", Len("$KixFormsKeyName1")-11,12)) ;Parse out KIXFORMS.DLL
$KixFormsExist2 = UCase(SubStr("$KixFormsKeyName2", Len("$KixFormsKeyName2")-11,12)) ;Parse out KIXFORMS.DLL

If Not (($KixFormsExist1 = "KIXFORMS.DLL") Or ($KixFormsExist2 = "KIXFORMS.DLL")) ;Determine if the KIXFORMS keys are present
Shell ''$WindowsFolder\$SystemFolder\REGSVR32.EXE /s $WindowsFolder\System32\KIXFORMS.DLL''
$KixFormsCopied = 1
EndIf

;=======================================================================
;==========*****Done Checking for or Installing KIXFORMS*****===========
;=======================================================================
EndFunction


;========================================
;Generate the Login Box
;========================================
Function LoginWindow
;Form Basics
$Form = CreateObject("Kixtart.Form")
$Form.Caption = "User Login"
$Form.Icon = "%WINDIR%\System32\shell32.dll;45"
$Form.ScaleHeight = 240
$Form.ScaleWidth = 385
$Form.FontName = "Arial"
$Form.FontSize = 9
$Form.Center

;Banner Details
$FrameBanner = $Form.PictureBox
$FrameBanner.BackColor = $Form.RGB(255,255,255)
$FrameBanner.Height = 70
$FrameBanner.Left = 10
$FrameBanner.Top = 10
$FrameBanner.Width = $Form.ScaleWidth - 20

;Banner Picture
$PictureBanner = $FrameBanner.Image
$PictureBanner.Picture = "%WINDIR%\System32\shell32.dll;40"
$PictureBanner.Height = 60
$PictureBanner.Left = 5
$PictureBanner.Top = 5
$PictureBanner.Width = 60

;Frame Details
$FrameDetails = $Form.Frame("Login Information")
$FrameDetails.Height = $Form.ScaleHeight - ($FrameBanner.Height + $FrameBanner.Top) - 25;135
$FrameDetails.Left = $FrameBanner.Left
$FrameDetails.Top = $FrameBanner.Top + $FrameBanner.Height + 15;95
$FrameDetails.Width = $Form.ScaleWidth - 20

;Username Box
$TextBoxUsername = $FrameDetails.TextBox
$TextBoxUsername.Height = 20
$TextBoxUsername.Left = $FrameDetails.Left + 90;104
$TextBoxUsername.Top = 24
$TextBoxUsername.Text = @USERID
$TextBoxUsername.Width = $FrameDetails.Width - 110 ;161

$LabelBoxUsername = $FrameDetails.Label
$LabelBoxUsername.Caption = "Username:"
$LabelBoxUsername.Height = $TextBoxUsername.Height
$LabelBoxUsername.Width = 75
$LabelBoxUsername.Left = $TextBoxUsername.Left - $LabelBoxUsername.Width
$LabelBoxUsername.Top = $TextBoxUsername.Top

;Password Box
$TextBoxPassword = $FrameDetails.TextBox
$TextBoxPassword.Height = 20
$TextBoxPassword.Left = $FrameDetails.Left + 90 ;104
$TextBoxPassword.PasswordChar = "*"
$TextBoxPassword.Top = 48
$TextBoxPassword.Width = $FrameDetails.Width - 110 ;161

$LabelBoxPassword = $FrameDetails.Label("Password:")
$LabelBoxPassword.Width = 75
$LabelBoxPassword.Left = $TextBoxPassword.Left - $LabelBoxPassword.Width
$LabelBoxPassword.Top = $TextBoxPassword.Top

;Domain Name Box
$TextBoxDomain = $FrameDetails.TextBox
$TextBoxDomain.Height = 19
$TextBoxDomain.Left = $FrameDetails.Left + 90 ;104
$TextBoxDomain.Top = 72
$TextBoxDomain.Text = @LDOMAIN
$TextBoxDomain.Width = $FrameDetails.Width - 110 ;161

$LabelBoxDomain = $FrameDetails.Label
$LabelBoxDomain.Caption = "Domain:"
$LabelBoxDomain.Height = $TextBoxDomain.Height
$LabelBoxDomain.Width = 75
$LabelBoxDomain.Left = $TextBoxDomain.Left - $LabelBoxDomain.Width
$LabelBoxDomain.Top = $TextBoxDomain.Top

;Banner Text and Picture
$FrameBanner.FontSize = 20
$FrameBanner.FontName = "lucida"
$FrameBanner.ForeColor = 0
$FrameBanner.FontBold = 1
$FrameBanner.PrintXY(70,0,"Network Login")
$FrameBanner.FontSize = 14
$FrameBanner.ForeColor = $Form.RGB(0,100,100)
$FrameBanner.PrintXY(71,28,"Hello @FULLNAME")
$FrameBanner.FontBold = 0
$FrameBanner.FontSize = 8
$FrameBanner.ForeColor = $Form.RGB(0,50,200)
$FrameBanner.PrintXY(71,50,"Type in your Login ID and Password")
$FrameBanner.FontSize = 10

;Login Button
$CmdUserLogin = $FrameDetails.CommandButton("Login")
$CmdUserLogin.Default = 1 ;True
$CmdUserLogin.FontName = "Arial"
$CmdUserLogin.FontSize = 10
$CmdUserLogin.FontBold = 1
$CmdUserLogin.Left = 105
$CmdUserLogin.Top = 103
$CmdUserLogin.Width = 78
$CmdUserLogin.Height = 19
$CmdUserLogin.OnClick = "CmdUserLogin_Click()"

;Exit Button
$CmdExit = $FrameDetails.CommandButton("Exit")
$CmdExit.FontName = "Arial"
$CmdExit.FontSize = 10
$CmdExit.FontBold = 1
$CmdExit.Top = 103
$CmdExit.Width = 80
$CmdExit.Height = 19
$CmdExit.Left = 188
$CmdExit.OnClick = "quit()"

;Get Lengths
$TextBoxUsername.SelLength = Len($TextBoxUsername.Text)
$TextBoxPassword.SelLength = Len($TextBoxPassword.Text)
$TextBoxDomain.SelLength = Len($TextBoxDomain.Text)

;Execute Form
$Form.Show
$TextBoxUsername.SetFocus

While $Form.Visible
$Nul = Execute($Form.DoEvents)
Loop
EndFunction


;========================================
;Login Button Clicked Function
;========================================
Function CmdUserLogin_Click()
If $TextBoxUsername.Text = ""
$Nul = $Form.MsgBox("You must specify a username before clicking LOGIN.", "Invalid Username",16)
$TextBoxUsername.Text = $StringUsername
Exit Sub
Else
$StringUsername = $TextBoxUsername.Text
EndIf

If $TextBoxPassword.Text = ""
$Nul = $Form.MsgBox("You must specify a password before clicking LOGIN.", "Invalid Password",16)
$TextBoxPassword.Text = $StringPassword
Exit Sub
Else
$StringPassword = $TextBoxPassword.Text
EndIf

If $TextBoxDomain.Text = ""
$Nul= $Form.MsgBox("You must specify a domain before clicking LOGIN.", "Invalid Domain",16)
$TextBoxDomain.Text = $StringDomain
Exit Sub
Else
$StringDomain = $TextBoxDomain.Text
EndIf

$Form.Hide
EndFunction






Edited by dgraham (2006-04-17 06:56 PM)