Link to home
Start Free TrialLog in
Avatar of fatp
fatp

asked on

Network Map and batch files

what is wrong with the script?
--------------------------------------------------------------
net use u: \\Server\folder /USER:blah blah
fc c:\qc\qc.bat u:\updatecmd\qc.bat
if %errorlevel% EQU 0 goto :EOF
fc c:\qc\qc.bat u:\updatecmd\qc.bat
if not %errorlevel% EQU 0 goto :UPDATE
goto :EOF

:UPDATE
copy /Y u:\updatecmd\qc.bat c:\qc\qc.bat

:EOF
-------------------------------------------------------------

When I use this script into a session, everything work but when I put it into a at command or with the task scheduler(I tried with systen and other account from task scheduller) and it doest work at all

Now I'm asking myselft....is it the script or it just the facq that there is no map possible into a batch fille run with at?

Btw fc is in the systemroot/system32 folder
ASKER CERTIFIED SOLUTION
Avatar of dlwyatt82
dlwyatt82
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of fatp
fatp

ASKER

Is there a way to give a username and password with the UNC path trought a script? If so...please tell me!
It's already included in my previous reply :) The "net use" statement is almost exactly the same, just leave out the drive letter.
Avatar of oBdA
There are several small issues with this script. You're not specifying the domain to go with the user name, so the target server is looking for a local account of that name, which it won't find (assuming that the account you're using is a domain account).
The proper syntax for the "net use" command in your case would be
net use X: \\server\share password /user:domain\user

In addition:
* There's no need to run the fc command twice
* "goto"s don't need the colon to jump to a self-defined label
* The ":eof" label is predefined in W2k
* The common errorlevel check is "if errorlevel x ..."
* You're not releasing the mapped drive at the end of the script

Your script should work if changed as follows:

--------------------------------------------------------------
@echo off
net use U: \\Server\folder blah /USER:BlahDomain\blah /persistent:no
fc C:\qc\qc.bat U:\updatecmd\qc.bat
if not %errorlevel% 1 goto leave

copy /Y U:\updatecmd\qc.bat C:\qc\qc.bat

:leave
net use U: /delete
--------------------------------------------------------------
Avatar of fatp

ASKER

OK i'm gonna check for both anser next week....thanks a lot!!
the only problem is that I'm on vacation for the week =)