?
Solved

Network Map and batch files

Posted on 2004-08-06
5
Medium Priority
?
831 Views
Last Modified: 2010-04-14
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
0
Comment
Question by:fatp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 14

Accepted Solution

by:
dlwyatt82 earned 500 total points
ID: 11737963
I am having trouble remembering for certain, but I believe you can't map drive letters from a script running in a scheduled task. Instead, just use the UNC path throughout your script:

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

net use \\Server\folder /USER:blah blah
fc c:\qc\qc.bat \\Server\folder\updatecmd\qc.bat
if %errorlevel% EQU 0 goto :EOF
fc c:\qc\qc.bat \\Server\folder\updatecmd\qc.bat
if not %errorlevel% EQU 0 goto :UPDATE
goto :EOF

:UPDATE
copy /Y \\Server\folder\updatecmd\qc.bat c:\qc\qc.bat

:EOF

---------------------------------------------------------------
0
 

Author Comment

by:fatp
ID: 11738345
Is there a way to give a username and password with the UNC path trought a script? If so...please tell me!
0
 
LVL 14

Expert Comment

by:dlwyatt82
ID: 11740094
It's already included in my previous reply :) The "net use" statement is almost exactly the same, just leave out the drive letter.
0
 
LVL 85

Expert Comment

by:oBdA
ID: 11742095
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
--------------------------------------------------------------
0
 

Author Comment

by:fatp
ID: 11746535
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 =)
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
The Summer 2017 Scholarship Winners have been announced!
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month10 days, 12 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question