• Sign in to Neowin Faster!

    Create an account on Neowin to contribute and support the site.

Sign in to follow this  

Secure use of passwords in batch files?

Recommended Posts

unknownsoldierX    1

One thing for starters, youre missing a comma after the robocopy options:

1=/mir /dcopy:T /copy:DATO /xd,"D:\Patrick\Downloads" "D:\Patrick\Desktop" /xa:h,D:\Patrick,\\DOWNSTAIRS\Patrick$

Then theres the options that appear in the wrong place /xa:h

1=/mir /dcopy:T /copy:DATO /xd,"D:\Patrick\Downloads" "D:\Patrick\Desktop" /xa:h,D:\Patrick,\\DOWNSTAIRS\Patrick$

It should be:

1=/mir /dcopy:T /copy:DATO /xd /xa:h,"D:\Patrick\Downloads" "D:\Patrick\Desktop" ,D:\Patrick,\\DOWNSTAIRS\Patrick$

The next issue is why there are 3 sets of folders listed:

"D:\Patrick\Downloads" "D:\Patrick\Desktop" ,D:\Patrick,\\DOWNSTAIRS\Patrick$

As noted before, and in the top of the script, the ini file format i used was:

job number = robocopy optionscommasource foldercommadestination folder

No, those options are correct. This works on the command line:

robocopy.exe "D:\Patrick" \\DOWNSTAIRS\Patrick$ /mir /dcopy:T /copy:DATO /xd "D:\Patrick\Downloads" "D:\Patrick\Desktop" /xa:h

/xd means exclude directory. I don't want Downloads or Desktop copied.

Share this post


Link to post
Share on other sites
Prt Scr    40

No, those options are correct. This works on the command line:

robocopy.exe "D:\Patrick" \\DOWNSTAIRS\Patrick$ /mir /dcopy:T /copy:DATO /xd/xa:h

/xd means exclude directory. I don't want Downloads or Desktop copied.

Then it needs to be:

1=/mir /dcopy:T /copy:DATO /xd "D:\Patrick\Downloads" "D:\Patrick\Desktop" /xa:h,D:\Patrick,\\DOWNSTAIRS\Patrick$

Share this post


Link to post
Share on other sites
unknownsoldierX    1

Then it needs to be:

1=/mir /dcopy:T /copy:DATO /xd "D:\Patrick\Downloads" "D:\Patrick\Desktop" /xa:h,D:\Patrick,\\DOWNSTAIRS\Patrick$

Look back at my post. That's exactly what I have.

Share this post


Link to post
Share on other sites
Prt Scr    40

Look back at my post. That's exactly what I have.

too many late nights....

Was thinking about this issue while i was on the train to my country hideout on thursday, and its my fault it isnt running, forgot you were backing up to a network location, the destination folder check is only checking and parsing errors for physical drives

sometimes im as thick as ****

what you see in the log is destination drive as ]

because my physical drive check first strips the letter of the drive (i.e. z:\ becomes z) to check to see if its the truecrypt drive which we know will fail a drivestatus request...when you shove a network path in there it goes from \\ to \, and fails when it requests the status of drive \

You can try the following code in the mean time , as a quick patch job, Ill fix it when get home in a couple of days, currently having to type this on a mac in country nsw and i hate macs....this has to be the worst keyboard in history, i swear it was made by the same company that makes tic tacs.....no useful keys like end or home or page up/down, cut&paste doesnt work as on a civilized pc...if it was mine id have heaved it out of the window by now, its taken 3 times as long to type this message on this hopeless apple crap...even the sinclair had a better keyboard than this

I actually threatened to stop talking to my family i they bought this thing...why oh why didnt i follow through....

Of course fixing the network path for the destination means now that ive woken up i will fix it for the source folder check as well

As i may have mentioned im not exactly as im my prime mentally as i was a few years ago when i was doing this gear in my sleep

replace this section

                ;get the pure letter of the drive to check against the truecrypt mounted drive letter for the current job
                ;if its the same, we already know it exists and we skip the next part of the drive check. If we dont check
                ;for a match here and the truyecrypt drive letter makes it into the next check it will FAIL as even though
                ;the truecrypt drive is mounted, it will report UNKNOWN to DriveStatus. This "error" is because TrueCrypt is a container, not a real drive.
                $CheckDestinationFolder = StringLeft($CopyDestination, 1)
                ;check destination drive exists - no point always testing if folder exists as the job may be creating a folder
                ConsoleWrite(@CRLF & "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....")
                FileWriteLine($Log, "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....")
                If $CheckDestinationFolder <> $TC_DriveLetter Then
                        $CheckDestinationFolder2 = DriveStatus(StringLeft($CopyDestination, 3))
                        Select
                                Case "UNKNOWN"
                                        ConsoleWrite(@CRLF & "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....FAILED: UNKNOWN" & _
                                        @CRLF & "ERROR returned message - UKNOWN - Drive may be unformatted (RAW).")
                                        FileWriteLine($Log, "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....FAILED: UNKNOWN" & _
                                        @CRLF & "Drive may be unformatted (RAW).")
                                        ;decrease the amount of successful jobs by 1
                                        $NumberOfJobs -= 1
                                        ;skip to next job
                                        ContinueLoop
                                Case "READY"
                                        ConsoleWrite(@CRLF & "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....SUCCESS: DRIVE READY")
                                        FileWriteLine($Log, "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....SUCCESS: DRIVE READY")
                                Case "INVALID"
                                        ConsoleWrite(@CRLF & "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder &" exists and is accessible....FAILED: INVALID" & _
                                        @CRLF & "ERROR returned message - INVALID - May indicate the drive letter does not exist or that a mapped network drive is inaccessible.")
                                        FileWriteLine($Log, "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....FAILED: INVALID" & _
                                        @CRLF & "ERROR returned message - INVALID - May indicate the drive letter does not exist or that a mapped network drive is inaccessible.")
                                        ;decrease the amount of successful jobs by 1
                                        $NumberOfJobs -= 1
                                        ;skip to next job
                                        ContinueLoop
                                Case "UNKNOWN"
                                        ConsoleWrite(@CRLF & "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....FAILED: UKNOWN" & _
                                        @CRLF & "ERROR returned message - INVALID - Drive may be unformatted (RAW).")
                                        FileWriteLine($Log, "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....FAILED: UKNOWN" & _
                                        @CRLF & "ERROR returned message - INVALID - Drive may be unformatted (RAW).")
                                        ;decrease the amount of successful jobs by 1
                                        $NumberOfJobs -= 1
                                        ;skip to next job
                                        ContinueLoop
                        EndSelect

                Else
                        ;write truecrypt container as destination to console/logfile
                        ConsoleWrite(@CRLF & "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....SUCCESS: DRIVE READY (Using TrueCrypt Container)")
                        FileWriteLine($Log, "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....SUCCESS: DRIVE READY (Using TrueCrypt Container)")
                EndIf

with:

                ;check for network path as destination
                $CheckNetworkDrive = StringLeft($CopyDestination, 2)
                If $CheckNetworkDrive = "\\" Then
                Else
                ;get the pure letter of the drive to check against the truecrypt mounted drive letter for the current job
                ;if its the same, we already know it exists and we skip the next part of the drive check. If we dont check
                ;for a match here and the truyecrypt drive letter makes it into the next check it will FAIL as even though
                ;the truecrypt drive is mounted, it will report UNKNOWN to DriveStatus. This "error" is because TrueCrypt is a container, not a real drive.
                $CheckDestinationFolder = StringLeft($CopyDestination, 1)
                ;check destination drive exists - no point always testing if folder exists as the job may be creating a folder
                ConsoleWrite(@CRLF & "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....")
                FileWriteLine($Log, "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....")
                If $CheckDestinationFolder <> $TC_DriveLetter Then
                        $CheckDestinationFolder2 = DriveStatus(StringLeft($CopyDestination, 3))
                        Select
                                Case "UNKNOWN"
                                        ConsoleWrite(@CRLF & "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....FAILED: UNKNOWN" & _
                                        @CRLF & "ERROR returned message - UKNOWN - Drive may be unformatted (RAW).")
                                        FileWriteLine($Log, "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....FAILED: UNKNOWN" & _
                                        @CRLF & "Drive may be unformatted (RAW).")
                                        ;decrease the amount of successful jobs by 1
                                        $NumberOfJobs -= 1
                                        ;skip to next job
                                        ContinueLoop
                                Case "READY"
                                        ConsoleWrite(@CRLF & "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....SUCCESS: DRIVE READY")
                                        FileWriteLine($Log, "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....SUCCESS: DRIVE READY")
                                Case "INVALID"
                                        ConsoleWrite(@CRLF & "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder &" exists and is accessible....FAILED: INVALID" & _
                                        @CRLF & "ERROR returned message - INVALID - May indicate the drive letter does not exist or that a mapped network drive is inaccessible.")
                                        FileWriteLine($Log, "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....FAILED: INVALID" & _
                                        @CRLF & "ERROR returned message - INVALID - May indicate the drive letter does not exist or that a mapped network drive is inaccessible.")
                                        ;decrease the amount of successful jobs by 1
                                        $NumberOfJobs -= 1
                                        ;skip to next job
                                        ContinueLoop
                                Case "UNKNOWN"
                                        ConsoleWrite(@CRLF & "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....FAILED: UKNOWN" & _
                                        @CRLF & "ERROR returned message - INVALID - Drive may be unformatted (RAW).")
                                        FileWriteLine($Log, "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....FAILED: UKNOWN" & _
                                        @CRLF & "ERROR returned message - INVALID - Drive may be unformatted (RAW).")
                                        ;decrease the amount of successful jobs by 1
                                        $NumberOfJobs -= 1
                                        ;skip to next job
                                        ContinueLoop
                        EndSelect

                Else
                        ;write truecrypt container as destination to console/logfile
                        ConsoleWrite(@CRLF & "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....SUCCESS: DRIVE READY (Using TrueCrypt Container)")
                        FileWriteLine($Log, "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....SUCCESS: DRIVE READY (Using TrueCrypt Container)")
                EndIf
                EndIf

Share this post


Link to post
Share on other sites
unknownsoldierX    1
User Credentials:  ACCEPTED
User Credentials:  Username and/or Password recognised on:  UPSTAIRS

Attempting to mount truecrypt volume:  "\\DOWNSTAIRS\Locked$\backups"  on drive letter:  x ....
Using command line:  "C:\Program Files\TeraCopy\TrueCrypt.exe" /q /v "\\DOWNSTAIRS\Locked$\backups" /lx /p password
Attempting to mount truecrypt volume:  "\\DOWNSTAIRS\Locked$\backups"  on drive letter:  x ....MOUNTED

Attempting to open job list file:  D:\Programs\backups\robocopy.ini ....
Attempting to open job list file:  D:\Programs\backups\robocopy.ini ....SUCCESSFUL

Processing jobs....

Job number:  1  starting...
Job number:  1  RoboCopy Options:  /mir /dcopy:T /copy:DATO /xa:h
Job number:  1  Source Folder:  "D:\Temp"
Job number:  1  Destination Folder:  "H:\Temp"
Job number:  1  Checking source folder:  "D:\Temp" exists....
Job number:  1  Checking source folder:  "D:\Temp" exists....SUCCESS
Job number:  1  Checking destination drive:  H exists and is accessible....
Job number:  1  Checking destination drive:  H exists and is accessible....FAILED: UNKNOWN
Drive may be unformatted (RAW).

1  total jobs submitted for  processing
0  of  1  jobs completed successfully

Attempting to unmount truecrypt volume:  "\\DOWNSTAIRS\Locked$\backups"  on drive letter:  x ....
Attempting to unmount truecrypt volume:  "\\DOWNSTAIRS\Locked$\backups"  on drive letter:  x ....FAILED
ExitCode:  0TrueCrypt returned error:  0
Attempting to unmount truecrypt volume:  "\\DOWNSTAIRS\Locked$\backups"  on drive letter:  x ....UNMOUNTED

Share this post


Link to post
Share on other sites
Prt Scr    40

User Credentials:  ACCEPTED
User Credentials:  Username and/or Password recognised on:  UPSTAIRS

Attempting to mount truecrypt volume:  "\\DOWNSTAIRS\Locked$\backups"  on drive letter:  x ....
Using command line:  "C:\Program Files\TeraCopy\TrueCrypt.exe" /q /v "\\DOWNSTAIRS\Locked$\backups" /lx /p password
Attempting to mount truecrypt volume:  "\\DOWNSTAIRS\Locked$\backups"  on drive letter:  x ....MOUNTED

Attempting to open job list file:  D:\Programs\backups\robocopy.ini ....
Attempting to open job list file:  D:\Programs\backups\robocopy.ini ....SUCCESSFUL

Processing jobs....

Job number:  1  starting...
Job number:  1  RoboCopy Options:  /mir /dcopy:T /copy:DATO /xa:h
Job number:  1  Source Folder:  "D:\Temp"
Job number:  1  Destination Folder:  "H:\Temp"
Job number:  1  Checking source folder:  "D:\Temp" exists....
Job number:  1  Checking source folder:  "D:\Temp" exists....SUCCESS
Job number:  1  Checking destination drive:  H exists and is accessible....
Job number:  1  Checking destination drive:  H exists and is accessible....FAILED: UNKNOWN
Drive may be unformatted (RAW).

1  total jobs submitted for  processing
0  of  1  jobs completed successfully

Attempting to unmount truecrypt volume:  "\\DOWNSTAIRS\Locked$\backups"  on drive letter:  x ....
Attempting to unmount truecrypt volume:  "\\DOWNSTAIRS\Locked$\backups"  on drive letter:  x ....FAILED
ExitCode:  0TrueCrypt returned error:  0
Attempting to unmount truecrypt volume:  "\\DOWNSTAIRS\Locked$\backups"  on drive letter:  x ....UNMOUNTED

Back home again, on a windows machine

Okay, fair cop, i will always admit when ive made a mistake

In this case you got the above error because i used Select/EndSelect when i should have used Switch/EndSwitch in the drive status check

And i also doubled up: Case "UNKNOWN" instead of "NOTREADY" ...fixed

I can confirm that both hard drive and network destinations work with the corrections

I will add checking for a network source folder and then post the complete code later tonight

existing code

                ;check for network path as destination
                $CheckNetworkDrive = StringLeft($CopyDestination, 2)
                If $CheckNetworkDrive = "\\" Then
                Else
                ;get the pure letter of the drive to check against the truecrypt mounted drive letter for the current job
                ;if its the same, we already know it exists and we skip the next part of the drive check. If we dont check
                ;for a match here and the truyecrypt drive letter makes it into the next check it will FAIL as even though
                ;the truecrypt drive is mounted, it will report UNKNOWN to DriveStatus. This "error" is because TrueCrypt is a container, not a real drive.
                $CheckDestinationFolder = StringLeft($CopyDestination, 1)
                ;check destination drive exists - no point always testing if folder exists as the job may be creating a folder
                ConsoleWrite(@CRLF & "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....")
                FileWriteLine($Log, "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....")
                If $CheckDestinationFolder <> $TC_DriveLetter Then
                        $CheckDestinationFolder2 = DriveStatus(StringLeft($CopyDestination, 3))
                        Select
                                Case "UNKNOWN"
                                        ConsoleWrite(@CRLF & "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....FAILED: UNKNOWN" & _
                                        @CRLF & "ERROR returned message - UKNOWN - Drive may be unformatted (RAW).")
                                        FileWriteLine($Log, "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....FAILED: UNKNOWN" & _
                                        @CRLF & "Drive may be unformatted (RAW).")
                                        ;decrease the amount of successful jobs by 1
                                        $NumberOfJobs -= 1
                                        ;skip to next job
                                        ContinueLoop
                                Case "READY"
                                        ConsoleWrite(@CRLF & "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....SUCCESS: DRIVE READY")
                                        FileWriteLine($Log, "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....SUCCESS: DRIVE READY")
                                Case "INVALID"
                                        ConsoleWrite(@CRLF & "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder &" exists and is accessible....FAILED: INVALID" & _
                                        @CRLF & "ERROR returned message - INVALID - May indicate the drive letter does not exist or that a mapped network drive is inaccessible.")
                                        FileWriteLine($Log, "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....FAILED: INVALID" & _
                                        @CRLF & "ERROR returned message - INVALID - May indicate the drive letter does not exist or that a mapped network drive is inaccessible.")
                                        ;decrease the amount of successful jobs by 1
                                        $NumberOfJobs -= 1
                                        ;skip to next job
                                        ContinueLoop
                                Case "UNKNOWN"
                                        ConsoleWrite(@CRLF & "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....FAILED: UKNOWN" & _
                                        @CRLF & "ERROR returned message - INVALID - Drive may be unformatted (RAW).")
                                        FileWriteLine($Log, "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....FAILED: UKNOWN" & _
                                        @CRLF & "ERROR returned message - INVALID - Drive may be unformatted (RAW).")
                                        ;decrease the amount of successful jobs by 1
                                        $NumberOfJobs -= 1
                                        ;skip to next job
                                        ContinueLoop
                        EndSelect

                Else
                        ;write truecrypt container as destination to console/logfile
                        ConsoleWrite(@CRLF & "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....SUCCESS: DRIVE READY (Using TrueCrypt Container)")
                        FileWriteLine($Log, "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....SUCCESS: DRIVE READY (Using TrueCrypt Container)")
                EndIf
                EndIf

corrected:

                ;check for network path as destination
                $CheckNetworkDrive = StringLeft($CopyDestination, 2)
                If $CheckNetworkDrive = "\\" Then
                Else
                ;get the pure letter of the drive to check against the truecrypt mounted drive letter for the current job
                ;if its the same, we already know it exists and we skip the next part of the drive check. If we dont check
                ;for a match here and the truyecrypt drive letter makes it into the next check it will FAIL as even though
                ;the truecrypt drive is mounted, it will report UNKNOWN to DriveStatus. This "error" is because TrueCrypt is a container, not a real drive.
                $CheckDestinationFolder = StringLeft($CopyDestination, 1)
                ;check destination drive exists - no point always testing if folder exists as the job may be creating a folder
                ConsoleWrite(@CRLF & "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....")
                FileWriteLine($Log, "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....")
                If $CheckDestinationFolder <> $TC_DriveLetter Then
                        $CheckDestinationFolder2 = DriveStatus(StringLeft($CopyDestination, 3))
                        Switch $CheckDestinationFolder2
                                Case "UNKNOWN"
                                        ConsoleWrite(@CRLF & "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....FAILED: UNKNOWN" & _
                                        @CRLF & "ERROR returned message - UKNOWN - Drive may be unformatted (RAW).")
                                        FileWriteLine($Log, "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....FAILED: UNKNOWN" & _
                                        @CRLF & "Drive may be unformatted (RAW).")
                                        ;decrease the amount of successful jobs by 1
                                        $NumberOfJobs -= 1
                                        ;skip to next job
                                        ContinueLoop
                                Case "READY"
                                        ConsoleWrite(@CRLF & "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....SUCCESS: DRIVE READY")
                                        FileWriteLine($Log, "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....SUCCESS: DRIVE READY")
                                Case "NOTREADY"
                                        ConsoleWrite(@CRLF & "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....FAILED: NOTREADY" & _
                                        @CRLF & "ERROR returned message - NOTREADY - Typical of floppy and CD drives that do not contain media.")
                                        FileWriteLine($Log, "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....FAILED: NOTREADY" & _
                                        @CRLF & "ERROR returned message - NOTREADY - Typical of floppy and CD drives that do not contain media.")
                                        ;decrease the amount of successful jobs by 1
                                        $NumberOfJobs -= 1
                                        ;skip to next job
                                        ContinueLoop
                                Case "INVALID"
                                        ConsoleWrite(@CRLF & "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder &" exists and is accessible....FAILED: INVALID" & _
                                        @CRLF & "ERROR returned message - INVALID - May indicate the drive letter does not exist or that a mapped network drive is inaccessible.")
                                        FileWriteLine($Log, "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....FAILED: INVALID" & _
                                        @CRLF & "ERROR returned message - INVALID - May indicate the drive letter does not exist or that a mapped network drive is inaccessible.")
                                        ;decrease the amount of successful jobs by 1
                                        $NumberOfJobs -= 1
                                        ;skip to next job
                                        ContinueLoop

                        EndSwitch

                Else
                        ;write truecrypt container as destination to console/logfile
                        ConsoleWrite(@CRLF & "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....SUCCESS: DRIVE READY (Using TrueCrypt Container)")
                        FileWriteLine($Log, "Job number:  " & $i &  "  Checking destination drive:  " & $CheckDestinationFolder & " exists and is accessible....SUCCESS: DRIVE READY (Using TrueCrypt Container)")
                EndIf
                EndIf

Share this post


Link to post
Share on other sites
unknownsoldierX    1
User Credentials:  ACCEPTED
User Credentials:  Username and/or Password recognised on:  UPSTAIRS

Attempting to mount truecrypt volume:  "\\DOWNSTAIRS\Locked$\backups"  on drive letter:  x ....
Using command line:  "C:\Program Files\TeraCopy\TrueCrypt.exe" /q /v "\\DOWNSTAIRS\Locked$\backups" /lx /p password
Attempting to mount truecrypt volume:  "\\DOWNSTAIRS\Locked$\backups"  on drive letter:  x ....MOUNTED

Attempting to open job list file:  D:\Programs\backups\robocopy.ini ....
Attempting to open job list file:  D:\Programs\backups\robocopy.ini ....SUCCESSFUL

Processing jobs....

Job number:  1  starting...
Job number:  1  RoboCopy Options:  /mir /dcopy:T /copy:DATO /xa:h
Job number:  1  Source Folder:  "D:\Temp"
Job number:  1  Destination Folder:  "H:\Temp"
Job number:  1  Checking source folder:  "D:\Temp" exists....
Job number:  1  Checking source folder:  "D:\Temp" exists....SUCCESS
Job number:  1  Checking destination drive:  H exists and is accessible....
Job number:  1  Checking destination drive:  H exists and is accessible....SUCCESS: DRIVE READY
Job number:  1  ROBOCOPY reports:  NO CHANGE **** PARTIAL SUCCESS **** - CHECK ROBOCOPY LOG OR FURTHER INFO

1  total jobs submitted for  processing
1  of  1  jobs completed successfully

Attempting to unmount truecrypt volume:  "\\DOWNSTAIRS\Locked$\backups"  on drive letter:  x ....
Attempting to unmount truecrypt volume:  "\\DOWNSTAIRS\Locked$\backups"  on drive letter:  x ....FAILED
ExitCode:  0TrueCrypt returned error:  0
Attempting to unmount truecrypt volume:  "\\DOWNSTAIRS\Locked$\backups"  on drive letter:  x ....UNMOUNTED

Share this post


Link to post
Share on other sites
Prt Scr    40

Okay, script updated

Added:

* Checking for network paths as source/destination

* Domain/ComputerName extracted from path, Domain/ComputerName is then pinged to make sure it exists, is it passes then the share name is tested, if that passes, the copy job continues, otherwise as with other failures, it skips to the next job

Changed:

* Some of the text and labels, for example SUCCESS is replaced by OK

* Generally shortened long output strings as much as i thought i could and remain informative.

I thought id attach the script this time instead of bloating the thread any further. Just need to rename the extension from .txt to .au3 (the forum doesnt allow uploading of .au3)

tcrobocopy.txt

As for your unmounting error, all i can say is that iuve looked into it from several angles and the only reason it can fail unmounting is if you have files to the truecrypt volume open. Dont have any programs trying to or actually accessing the volume. Make sure you dont have say explorer browsing that folder while the script is running...tat is as i may have said before, ids THE ONLY way i can get it to fail.

Share this post


Link to post
Share on other sites
Prt Scr    40

Updated again...added writing of "skipping to next job..." to console/log file if theres a failure and more than 1 job

Purely cosmetic.

tcrobocopy.txt

Share this post


Link to post
Share on other sites
unknownsoldierX    1

I don't get permission errors for robocopy anymore, so that is working better. But the drive still doesn't mount. It says it's mounted but it never actually mounts.

I think I found the problem. Notice this in the copy log:

Using command line:  "C:\Program Files\TeraCopy\TrueCrypt.exe" /q /v "\\DOWNSTAIRS\Locked$\backups" [b]/lx[/b] /p password

There should be a space between the /l and the x. I'm not sure how to fix it.

Copylog

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "D:\Programs\Backups\backups.au3"    

User Credentials:  ACCEPTED
User Credentials:  Username and/or Password recognised on:  UPSTAIRS

Mounting truecrypt volume:  "\\DOWNSTAIRS\Locked$\backups"  on drive letter:  x ...
Using command line:  "C:\Program Files\TeraCopy\TrueCrypt.exe" /q /v "\\DOWNSTAIRS\Locked$\backups" /lx /p password
Mounting truecrypt volume:  "\\DOWNSTAIRS\Locked$\backups"  on drive letter:  x ...MOUNTED

Open job list file:  D:\Programs\backups\Robocopy.ini ...
Open job list file:  D:\Programs\backups\Robocopy.ini ...OK

Processing jobs...

Job number:  1  starting...
Job number:  1  RoboCopy Options:  /mir /dcopy:T /copy:DT /xa:h
Job number:  1  Source Folder:  "D:\Temp"
Job number:  1  Destination Folder:  "H:\Temp"
Job number:  1  Source:  D:\Temp exists...
Job number:  1  Source:  D:\Temp exists...OK
Job number:  1  Destination:  H:\Temp exists...
Job number:  1  Destination:  H exists and is accessible....
Job number:  1  Destination:  H exists...OK: DRIVE READY
Job number:  1  ROBOCOPY reports:  NO CHANGE **** PARTIAL SUCCESS **** - CHECK ROBOCOPY LOG OR FURTHER INFO

1  total jobs submitted for  processing
1  of  1  jobs completed successfully

Attempting to unmount truecrypt volume:  "\\DOWNSTAIRS\Locked$\backups"  on drive letter:  x ....
Attempting to unmount truecrypt volume:  "\\DOWNSTAIRS\Locked$\backups"  on drive letter:  x ...FAIL
ExitCode:  0TrueCrypt returned error:  0
Attempting to unmount truecrypt volume:  "\\DOWNSTAIRS\Locked$\backups"  on drive letter:  x ....UNMOUNTED>Exit code: 0    Time: 2.814

Job_1_robocopy.log

-------------------------------------------------------------------------------
   ROBOCOPY     ::     Robust File Copy for Windows                              
-------------------------------------------------------------------------------

  Started : Fri Aug 06 12:03:59 2010

   Source : D:\Temp\
     Dest : H:\Temp\

    Files : *.*

  Options : *.* /S /E /COPY:DT /DCOPY:T /PURGE /MIR /XA:H /R:1000000 /W:30 

------------------------------------------------------------------------------

	                   0	D:\Temp\

------------------------------------------------------------------------------

               Total    Copied   Skipped  Mismatch    FAILED    Extras
    Dirs :         1         0         1         0         0         0
   Files :         0         0         0         0         0         0
   Bytes :         0         0         0         0         0         0
   Times :   0:00:00   0:00:00                       0:00:00   0:00:00

   Ended : Fri Aug 06 12:03:59 2010

Share this post


Link to post
Share on other sites
Prt Scr    40

I don't get permission errors for robocopy anymore, so that is working better. But the drive still doesn't mount. It says it's mounted but it never actually mounts.

I think I found the problem. Notice this in the copy log:

Using command line:  "C:\Program Files\TeraCopy\TrueCrypt.exe" /q /v "\\DOWNSTAIRS\Locked$\backups" [b]/lx[/b] /p password

There should be a space between the /l and the x. I'm not sure how to fix it.

Copylog

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "D:\Programs\Backups\backups.au3"    

User Credentials:  ACCEPTED
User Credentials:  Username and/or Password recognised on:  UPSTAIRS

Mounting truecrypt volume:  "\\DOWNSTAIRS\Locked$\backups"  on drive letter:  x ...
Using command line:  "C:\Program Files\TeraCopy\TrueCrypt.exe" /q /v "\\DOWNSTAIRS\Locked$\backups" /lx /p password
Mounting truecrypt volume:  "\\DOWNSTAIRS\Locked$\backups"  on drive letter:  x ...MOUNTED

Open job list file:  D:\Programs\backups\Robocopy.ini ...
Open job list file:  D:\Programs\backups\Robocopy.ini ...OK

Processing jobs...

Job number:  1  starting...
Job number:  1  RoboCopy Options:  /mir /dcopy:T /copy:DT /xa:h
Job number:  1  Source Folder:  "D:\Temp"
Job number:  1  Destination Folder:  "H:\Temp"
Job number:  1  Source:  D:\Temp exists...
Job number:  1  Source:  D:\Temp exists...OK
Job number:  1  Destination:  H:\Temp exists...
Job number:  1  Destination:  H exists and is accessible....
Job number:  1  Destination:  H exists...OK: DRIVE READY
Job number:  1  ROBOCOPY reports:  NO CHANGE **** PARTIAL SUCCESS **** - CHECK ROBOCOPY LOG OR FURTHER INFO

1  total jobs submitted for  processing
1  of  1  jobs completed successfully

Attempting to unmount truecrypt volume:  "\\DOWNSTAIRS\Locked$\backups"  on drive letter:  x ....
Attempting to unmount truecrypt volume:  "\\DOWNSTAIRS\Locked$\backups"  on drive letter:  x ...FAIL
ExitCode:  0TrueCrypt returned error:  0
Attempting to unmount truecrypt volume:  "\\DOWNSTAIRS\Locked$\backups"  on drive letter:  x ....UNMOUNTED>Exit code: 0    Time: 2.814

Job_1_robocopy.log

-------------------------------------------------------------------------------
   ROBOCOPY     ::     Robust File Copy for Windows                              
-------------------------------------------------------------------------------

  Started : Fri Aug 06 12:03:59 2010

   Source : D:\Temp\
     Dest : H:\Temp\

    Files : *.*

  Options : *.* /S /E /COPY:DT /DCOPY:T /PURGE /MIR /XA:H /R:1000000 /W:30 

------------------------------------------------------------------------------

	                   0	D:\Temp\

------------------------------------------------------------------------------

               Total    Copied   Skipped  Mismatch    FAILED    Extras
    Dirs :         1         0         1         0         0         0
   Files :         0         0         0         0         0         0
   Bytes :         0         0         0         0         0         0
   Times :   0:00:00   0:00:00                       0:00:00   0:00:00

   Ended : Fri Aug 06 12:03:59 2010

I hate to tell you, but theres no difference whether you put a space in there or not.

Ive made some more changes and will post it after i test, after i get some sleep, its almost 5am here....

Share this post


Link to post
Share on other sites
unknownsoldierX    1

It makes a difference when I do it at the command line.

"C:\Program Files\TrueCrypt\TrueCrypt.exe" /v \\DOWNSTAIRS\Locked$\backups /l X /p password /s /q

Works.

"C:\Program Files\TrueCrypt\TrueCrypt.exe" /v \\DOWNSTAIRS\Locked$\backups /lX /p password /s /q

Does not work. No errors, but the volume doesn't mount.

Share this post


Link to post
Share on other sites
Prt Scr    40

It makes a difference when I do it at the command line.

"C:\Program Files\TrueCrypt\TrueCrypt.exe" /v \\DOWNSTAIRS\Locked$\backups /l X /p password /s /q

Works.

"C:\Program Files\TrueCrypt\TrueCrypt.exe" /v \\DOWNSTAIRS\Locked$\backups /lX /p password /s /q

Does not work. No errors, but the volume doesn't mount.

Then you must have the only system in the world that does that because, quoting from the truecrypt documentation for mounting and unmounting (examples):

Dismount a volume mounted as the drive letter X (the main program window will not be displayed):

truecrypt /q /dx


Mount a volume called myvolume.tc using the password MyPassword, as the drive letter X. TrueCrypt will open an explorer window and beep; mounting will be automatic:

truecrypt /v myvolume.tc /lx /a /p MyPassword /e /b

Ill put the space in, but seriously, theres something weird in that i and the rest of the planet can use it without a space.

Share this post


Link to post
Share on other sites
unknownsoldierX    1

Just tried it again, and you're right, it does work without the space.

Share this post


Link to post
Share on other sites
Prt Scr    40

Okay

Added:

* Added/Left space after tc drive letter in command line for both mounting and unmounting

* Check that tc volume is still mounted BEFORE trying to unmount it (seemed a sane thing to do:) ) should clear up the errors you were getting when tc volume wasnt mounted in the first place

* A few other changes in the handling of errors when trying to copy to a tc volume that doesnt exist because it wasnt mounted!

tcrobocopy.txt

Share this post


Link to post
Share on other sites
Prt Scr    40

Okay

Fixed:

* incorrect order of robocopy options (i finally read a manual)

Added:

* summary counters for excluded jobs (jobs in the ini file with a # in front of the number) and jobs with errors

* date time stamping of log file(s)

2 versions:

v1 - Outputs separate log files for the main script output and each job

tcrobocopy_seperate_logs..txt

v2 (at request of OP) - Outputs all script and robocopy output to the one log file

tcrobocopy_all_in_one_log..txt

Share this post


Link to post
Share on other sites
amm.firas    0

I was trying to find a solution for this problem, converting .bat files to .exe will not ever solve the problem because any intermediate programmer can get the password easily so I?ve created a new command line tool that can help many others like us to encrypt the .bat file using X509 certificate.

You can find my tool under: http://securebatch.codeplex.com/

Enjoy it!

-Firas

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.