| 1. |
Solve : It doesn't works as a windows service? |
|
Answer» hi, A Windows service is automatically started when your system boots. It may be too early in the process to be mapping drives. Thank you for your help. let me try to explain in my poor english. the mapped drive is already there when service starts. i use this to create the service: net stop backup instsrv BACKUP REMOVE instsrv BACKUP c:\windows\system32\srvany.exe Reg add HKLM\SYSTEM\CurrentControlSet\Services\BACKUP\Parameters /v Application /d c:\windows\system32\backup.bat net start backup First i stop it (if it's running) then i remove it (if it exists) then i create it and i start it i made this batch because it is easier to create the service. the real problem here is (the mapped drive is already there when it runs as a service): local drive - running as a service - ok local drive - not running as a service - ok mapped drive - running as a service - NOT ok mapped drive - not running as a service - ok i hope you have any ideas The service starts before any user is logged in which I think is the problem with mapped drives. All the files probably need to be local or use UNC paths. Try using UNC paths....can't hurt. Good luck. First off all, I don't know how to use UNC Paths. Another way to put the problem (perhaps more easier to explain): i have a mapped drive here called Z (it's already mapped... i'm able to access it, and so on, and so on) in a comand line i wrote z: then xcopy z:\server\*.* "H:\backup\PC_SERVER\E\server\" /Y /I /k /D /H /C /E everything worked. After this test i made a batch file with the two lines:(z: it's already mapped... i'm able to access it, and so on, and so on) z: xcopy z:\server\*.* "H:\backup\PC_SERVER\E\server\" /Y /I /k /D /H /C /E i runned the batch file... everything's fine. Then i put this batch as a service(z: it's already mapped... i'm able to access it, and so on, and so on) nothing happened... Why? I noticed that running as a service, the batch file doesn't change to drive Z: (this only happen with mapped drives, with local drives it works fine) and if it doesn't change to z:, it is not able to xcopy z:\server and it stops Quote After this test i made a batch file with the two lines:(z: it's already mapped... i'm able to access it, and so on, and so on) It probably works because you are signed into the machine. When the batch file is run as a service, there is no user. Quote First off all, I don't know how to use UNC Paths. Sure you do. This is a UNC path: \\computername\sharename When you mapped the drive you used a UNC path: net use h: \\server\backup Why is it necessary to run a backup as a service? You can run the backup from the task scheduler (at startup) or even the startup folder found on the start menu. It would save yourself a lot of grief. Quote from: Sidewinder on January 27, 2010, 06:16:02 AM It probably works because you are signed into the machine. When the batch file is run as a service, there is no user. I just don't want the black window appears on screen even if it's minimizedQuote I just don't want the black window appears on screen even if it's minimized So that is what this is all about. Have you even tried to use the UNC paths? After using Google, I discovered this a common problem with mapped drives and the only realistic solution is the UNC method. Another alternative is to write a script that runs in Windows (VBScript is installed on your machine and does not require the cmd processor.) The problem is the XCOPY switches which may be difficult to duplicate in VBScript. Good luck. using UNC path i have the same problem our conversation pointed me to the security of a share folder... i BELIEVE the solution is to give the right access to the rigth users NETWORK SERVICE??? NETWORK??? ALL?? SYSTEM?? and others. or perhaps i will need to create a user and give him the access through network.... i don't know... but right now it seems that the problem is the service has no access rigths in mapped drive... i 'm going to study this... i will tell you my conclusions. thanks for your help After a search, my first idea was right... it was the access rights of users to mapped drives.... somewhere i read that a mapped drive to be accessed by a service, must be created by a service with administrator rights... suddenly i remember that i have the user administrador with password (created when i installed windows). so i changed my batch files: batch1 (to create the and start the service) net stop BACKUP instsrv BACKUP remove instsrv BACKUP c:\windows\system32\srvany.exe Reg add HKLM\SYSTEM\CurrentControlSet\Services\BACKUP\Parameters /v Application /d C:\windows\system32\backup.bat net start BACKUP batch2 (to be used as the service named BACKUP) net use z: \\server\www *********** /USER:server\administrator :START z: cd\ xcopy *.* "h:\test\" /Y /I /E /k /D /H /C goto START where *********** is the password of administrator Thank you so much. Our conversation helped me a lot. Any time you need something... i'm here ok?Thank you for getting back to us. It never hurts to learn something new. I admit that if the UNC method didn't work (it didn't), my next suggestion would not have been to have the service have administrator rights. Stick around. As on all forums there are many more questions than answers. We can use all the help we can get. Good luck. |
|