Sign in to follow this  
Followers 0
Jass

Problems with including Textfile under Windows Server 2003/Vist

6 posts in this topic

#1 ·  Posted (edited)

Hey out there,

I'm new to AutoIt and I wrote a small backupscript for a MSSQL-Database and some files.

The script should be used by our customers so I want them to edit a textfile with some variables to their need and the compiled script to just include the textfile.

That's the way I tried...

Backup.au3:

;Includes for functions _RunDOS and _Now()
#Include <Process.au3>
#include <Date.au3>
#include "Variables.txt"
#RequireAdmin

;BallonTip backup start
TrayTip("Backup aktiv","ADAMS Backup startet, Datenbank und elektronische Akte werden gesichert.",5,2)

;Shutdown SQL-Server, copy database files and restart SQL-Server
_RunDOS("net stop " & $sqlinstancename)
FileCopy($dirsqlserver & "\" & $dbname, $dirbackupdb & "\" & $dbname, 1)
FileCopy($dirsqlserver & "\" & $dblogname, $dirbackupdb & "\" & $dblogname, 1)
_RunDOS("net start " & $sqlinstancename)

;Copy files of "Elekotronische Akte"
DirCopy($direakte, $dirbackupeakte, 1)

;If not exists, create logfile and insert outcome
$file = FileOpen($dirlogfile & "\" & $logfilename, 1)
FileWrite($file, _Now() & ": ADAMS Backup erfolgreich erstellt. " & "Datenbank gesichert nach: " & $dirbackupdb & " ; Dateien elektronische Akte gesichert nach: " & $dirbackupeakte & @CRLF)
FileClose($file)

;BallonTip backup end
TrayTip("Backup beendet","ADAMS Backup erfolgreich beendet, Logfile aktualisiert.",5,1)
Sleep(5000)oÝ÷ Ø Ý¶¯j¸nW¬~íë®*mj·©§v)íè§r[y×âꮢÕZ®&ë-ÆÚ®¢ÛajÙh¢K%G­+ºÚ"µÍÐ]HÜÙ[ÚYHYÙH]ZH[ZHY?ÜÙH[ÕÒPÒQÎ[HZXÚÜÙH¿YHXÚÝÈÜÙ[X[Y[Ý[Ù[[Z]ÈXÚÝ[Ý[ÛY  ÌÌÎÉÌÌÎÉÌÌÎÂÓ[YHÔSTÙ[Ý[ÌÍÜÜ[[Ý[Ù[[YHH ][ÝÓTÔÔS    ÌÍÐQST×ÔÔSÑTT][ÝÂÓ[YH][[ËQ]ZH
[HÜX[[XÚ9BÌÍÙ[YHH  ][ÝÐQSTËY][ÝÂÓ[YH][[ËSÙÙ]ZH
[HÜX[[XÚ9BÌÍÙÙÛ[YHH  ][ÝÐQST×ÛÙË][ÝÂÑ]KUZXÚÈÈÔSTÙÂÌÍÙÜ[ÙH    ][ÝÐÎÌLÔÙÜ[[YIÌLÓZXÜÜÛÙÔSÙÌLÓTÔÔSIÌLÓTÔÔS    ÌLÑ]I][ÝÂÐXÚÝUZXÚÈ¿YH][[ËQ]ZY[ÌÍÙXÚÝH   ][ÝÑÌLÐXÚÝ    ÌLÑ][[É][ÝÂÕZXÚÈ[ZÝÛØÚ[ZÝBÌÍÙXZÝHH ][ÝÐÎÌLÔÙÜ[[YIÌLÒRÒÔ]X[]ÈÛX    ÌLÑ[ZÝÛØÚHZÝI][ÝÂÕZXÚÈ¿XÚÝ[ZÝÛØÚ[ZÝBÌÍÙXÚÝXZÝHH   ][ÝÑÌLÐXÚÝ    ÌLÑ]ZY[][ÝÂÕZXÚÈ¿YHÙÙ]ZBÌÍÙÙÙ[HH ][ÝÑÌLÐXÚÝ    ][ÝÂÓ[YHÙÙ]ZBÌÍÛÙÙ[[[YHH  ][ÝÓÙÙ[K    ][Ý

My problem is that the script runs great under Windows XP but not under Windows Vista or Windows Server 2003.

The SQL-Service is beeing ended and restartet but the commands for filecopy and dircopy doesn't work.

I also tried to put the declaration of the variables into the script itself and this works but I need them in a separate file.

Any ideas where to find the problem?

Cheers

Dennis

Edited by Jass

Share this post


Link to post
Share on other sites



I don't know why but my code i unreadable, so here one more time the full code:

backup.au3:

;Includes for functions _RunDOS and _Now()
#include <process.au3>
#include <Date.au3>
#include "Variables.txt"
#RequireAdmin

;BallonTip backup start
TrayTip("Backup aktiv","ADAMS Backup startet, Datenbank und elektronische Akte werden gesichert.",5,2)

;Shutdown SQL-Server, copy database files and restart SQL-Server
_RunDOS("net stop " & $sqlinstancename)
FileCopy($dirsqlserver & "\" & $dbname, $dirbackupdb & "\" & $dbname, 1)
FileCopy($dirsqlserver & "\" & $dblogname, $dirbackupdb & "\" & $dblogname, 1)
_RunDOS("net start " & $sqlinstancename)

;Copy files of "Elekotronische Akte"
DirCopy($direakte, $dirbackupeakte, 1)

;If not exists, create logfile and insert outcome
$file = FileOpen($dirlogfile & "\" & $logfilename, 1)
FileWrite($file, _Now() & ": ADAMS Backup erfolgreich erstellt. " & "Datenbank gesichert nach: " & $dirbackupdb & " ; Dateien elektronische Akte gesichert nach: " & $dirbackupeakte & @CRLF)
FileClose($file)

;BallonTip backup end
TrayTip("Backup beendet","ADAMS Backup erfolgreich beendet, Logfile aktualisiert.",5,1)
Sleep(5000)oÝ÷ Ø Ý¶­{_Wj¸nW¬·ZºÚ"µÍÐ]HÜÙ[ÚYHYÙH]ZH[ZHY?ÜÙH[ÕÒPÒQÎ[HZXÚÜÙH¿YHXÚÝÈÜÙ[X[Y[Ý[Ù[[Z]ÈXÚÝ[Ý[ÛY ÌÌÎÉÌÌÎÉÌÌÎÂÓ[YHÔSTÙ[Ý[ÌÍÜÜ[[Ý[Ù[[YHH ][ÝÓTÔÔS    ÌÍÐQST×ÔÔSÑTT][ÝÂÓ[YH][[ËQ]ZH
[HÜX[[XÚ9BÌÍÙ[YHH  ][ÝÐQSTËY][ÝÂÓ[YH][[ËSÙÙ]ZH
[HÜX[[XÚ9BÌÍÙÙÛ[YHH  ][ÝÐQST×ÛÙË][ÝÂÑ]KUZXÚÈÈÔSTÙÂÌÍÙÜ[ÙH    ][ÝÐÎÌLÔÙÜ[[YIÌLÓZXÜÜÛÙÔSÙÌLÓTÔÔSIÌLÓTÔÔS    ÌLÑ]I][ÝÂÐXÚÝUZXÚÈ¿YH][[ËQ]ZY[ÌÍÙXÚÝH   ][ÝÑÌLÐXÚÝ    ÌLÑ][[É][ÝÂÕZXÚÈ[ZÝÛØÚ[ZÝBÌÍÙXZÝHH ][ÝÐÎÌLÔÙÜ[[YIÌLÒRÒÔ]X[]ÈÛX    ÌLÑ[ZÝÛØÚHZÝI][ÝÂÕZXÚÈ¿XÚÝ[ZÝÛØÚ[ZÝBÌÍÙXÚÝXZÝHH   ][ÝÑÌLÐXÚÝ    ÌLÑ]ZY[][ÝÂÕZXÚÈ¿YHÙÙ]ZBÌÍÙÙÙ[HH ][ÝÑÌLÐXÚÝ    ][ÝÂÓ[YHÙÙ]ZBÌÍÛÙÙ[[[YHH  ][ÝÓÙÙ[K    ][Ý

Share this post


Link to post
Share on other sites

Hi,

maybe you should check your pathnames on the command line (especially for Vista).

As an example: On the command line there are your profiles in the "C:\users" folder. On the german GUI (in the explorer window) you see "C:\Benutzer" instead.

Please check first via CMD-Window if the path is really "C:\Programme" or if it's "C:\program files".

Share this post


Link to post
Share on other sites

Hi,

maybe you should check your pathnames on the command line (especially for Vista).

As an example: On the command line there are your profiles in the "C:\users" folder. On the german GUI (in the explorer window) you see "C:\Benutzer" instead.

Please check first via CMD-Window if the path is really "C:\Programme" or if it's "C:\program files".

Oh sorry it's my fault I copied the code from my XP script.

On Vista I changed the textfile as you said to "C:\program files" and tested it by inserting the path into the windows explorer, with success.

Share this post


Link to post
Share on other sites

Its hard to test your code specifically without setting it up in my environment, but in general, how are you handling UAC in Vista? I could see permissions potentially being a problem. You might also try logging in your script to see exactly where the issue is (or at least consolewrite when coding).

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  
Followers 0