Mourning the loss of our friend, WhitPhil.
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
 
DOS/PDA/Other
Tag Cloud
access audio black screen blue screen boot bsod connection crash dell desktop driver dvd email error excel excel 2003 firefox hard drive hardware hijackthis internet keyboard laptop malware monitor network networking outlook problem processor ram recovery router safe mode slow sound spyware tdlwsp.dll trojan upgrade vba video virus vista vundo windows windows 7 windows vista windows xp wireless
Search
Search for:
Tech Support Guy Forums > Operating Systems > DOS/PDA/Other >
Windows XP Task Scheduler Command Line Credentials Question

Tip: Click here to scan for System Errors and Optimize PC performance
[ Sponsored Link ]

 
Thread Tools
scrfix's Avatar
Computer Specs
Senior Member with 269 posts.
 
Join Date: May 2009
Experience: Computer Repair Expert
19-Aug-2009, 09:41 PM #16
damn I just tried that
net use Z \\Matts-laptop\f /Persistent:Yes

An error came back
System error 67 has occurred.
The network name cannot be found.

I have not looked the error up yet.
Squashman's Avatar
Distinguished Member with 14,983 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: IIAHYAYCESA,YAADA!
19-Aug-2009, 09:46 PM #17
I guess I am not seeing your point this exercise. If you have a shared resource on the network why would you go searching for it and then try to map to it.

I don't think there is anyway to determine if the share is a internal or external hard drive attached to the pc.

If you want to backup to it, just call the share name BACKUP.

Yes there are ways to detect shares on remote computers but you would waste all kinds of time and resources if you had to scan the entire subnet every time to do this. And why would you want to do this just for backup. Makes no sense to me. If you want to backup to a network share then just back it up to there.

You sure like to make things harder than they have to be.
__________________
I hate asking the same question twice!
How to ask questions the smart way!
Microsoft MVP - User Desktop Experience
TheOutcaste's Avatar
Computer Specs
Distinguished Member with 5,485 posts.
 
Join Date: Aug 2007
Location: Oregon, USA
Experience: Intermediate
19-Aug-2009, 09:50 PM #18
Check out Net View and Net Use
Net View \\pcname will show the shared resources, but there is no way to tell if it's an internal or external disk unless you include that in the share name.
The error 67 is because you forgot the colon:
net use Z: \\Matts-laptop\f /Persistent:Yes

Mapping the same share to two different drive letters can sometimes cause issues, so I use the following routine to check to see if a share is already mapped. If it is, it returns the drive letter. If not, it maps the share to the next available drive letter and returns the drive letter.
It also returns a flag to indicate whether the share was already mapped, or was just created. This flag can be used to let you delete shares you create, while leaving shares that already existed alone. Users get upset when you delete their mapped drives for some reason.

Code:
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::                    Subroutines
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:_MapChk
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Checks if a share is already mapped.
:: Arguments : "SharePath" returnvariable flagvariable [username [password]]
:: Returns   : Drive letter in returnvariable
::           : Flagvariable set to 0 if already mapped, 1 if new map
:: Usage
:: Call :_MapChk "path" rname fname [username password]
::      "path"   : Share to be mapped. Must be in quotes
::      rname    : This variable will be set to the mapped drive letter
::      fname    : Set to 0 if drive already mapped, 1 if a drive was mapped
::      username : Username to be used. Enter * if you wish to use currently logged on user
::      password : Password to use. Enter * if you wish to be prompted
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Setlocal EnableDelayedExpansion
If [%4]==[] Goto _Pchk1
Set _User=
If %4==* Goto _Pchk1
Set _User=/user:%4
:_Pchk1
Set _Pass=
If NOT [%5]==[] Set _Pass=%5
Set _t1=%~1
For /L %%I In (5,1,26) Do If NOT "!_t1:~%%I,1!"=="" Set _len=%%I
If !_len! LEQ 24 (
:: Pad with 20 trailing spaces and a period
  Set _t1=!_t1!                    .
  Set _t1=!_t1:~0,25!
  )
:: Add one trailing space and a period
Set _t1=!_t1! .
:: Trim off period
Set _t1=!_t1:~0,-1!
Set _Flag=0
:_MapChk1
For /F "Tokens=2*" %%I In ('net use ^|Find /I %1') Do (
 Set _Found=%%J
 Set _Found=!_Found:Microsoft Windows Network=!
 If /I !_Found!==!_t1! Set _PDrv=%%~dI
 )
If NOT [%_PDrv%]==[] EndLocal&Set %2=%_PDrv%&Set %3=%_Flag%&Goto :EOF
Set _Flag=1
Net Use * %_Pdrv% %1 %_User% %_Pass%
If NOT Errorlevel 1 Goto _MapChk1
EndLocal&Goto :EOF
Example of usage in my backup script:
Code:
Call :_MapChk "\\%_PCName%\AllUsers$" _Drv _DF
xcopy %_sw% %_Drv%\ "U:\Backups\%_PCName%\AllUsers" /exclude:xcldlst2.log+xcldlst3.log
If %_DF%==1 net use %_Drv% /DELETE
__________________
Microsoft MVP - Windows Desktop Experience
Of course I know all the answers ; I just don't always match the answers to the right questions
Are you aware of the New Signature Limitations?
scrfix's Avatar
Computer Specs
Senior Member with 269 posts.
 
Join Date: May 2009
Experience: Computer Repair Expert
19-Aug-2009, 09:51 PM #19
Point to the exercise is to learn. I will pick up anything I can and like to learn. I have numerous projects all the time and whatever I can learn to make things easier on me the better.

Obviously I did not know what it would take in order to accomplish that otherwise I would not have asked.

And God, oops I mean Jerry, seems to be a wealth of knowledge and always knows something that is extremely user-friendly and has never ceased to amaze me. When he does something, it just works. If I can learn from anyone willing to share, I will ask. I learn from any resource possible and as much as possible.
__________________
Wayne Leiser, Spectacular Computer Repair Computer Repair, Computer Services
World Famous Gift Baskets: Gift Baskets, Corporate Gifts
Resources LLC: Water Treatment Coagulation, Water Recycling
Squashman's Avatar
Distinguished Member with 14,983 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: IIAHYAYCESA,YAADA!
19-Aug-2009, 09:59 PM #20
Quote:
Originally Posted by scrfix View Post
damn I just tried that
net use Z \\Matts-laptop\f /Persistent:Yes

An error came back
System error 67 has occurred.
The network name cannot be found.

I have not looked the error up yet.
You named the share F?
scrfix's Avatar
Computer Specs
Senior Member with 269 posts.
 
Join Date: May 2009
Experience: Computer Repair Expert
19-Aug-2009, 10:02 PM #21
Jerry,

Thanks for the script. I am going to start breaking that down to try to see what it says.

Took a quick glance. How does it know whether or not you have internal drives using drive lettes. I see where you are using net use to determine the mapped drives.

What happens if it things the next available drive is F but that drive letter is already utilized by an external drive or a CD-Rom?

Squashman,

It is my kids computer and the drive letter is f so for testing it didn't need to be anything else. Shouldn't matter what it was named because the command is still the same, right?
__________________
Wayne Leiser, Spectacular Computer Repair Computer Repair, Computer Services
World Famous Gift Baskets: Gift Baskets, Corporate Gifts
Resources LLC: Water Treatment Coagulation, Water Recycling
Squashman's Avatar
Distinguished Member with 14,983 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: IIAHYAYCESA,YAADA!
19-Aug-2009, 10:08 PM #22
Do you not see the net use * in his script?
TheOutcaste's Avatar
Computer Specs
Distinguished Member with 5,485 posts.
 
Join Date: Aug 2007
Location: Oregon, USA
Experience: Intermediate
19-Aug-2009, 10:09 PM #23
net use * will use the next available drive letter. It won't try to use a drive letter that is already in use. It will use drive letters that have been assigned to flash drives or externals if they are not connected, so connecting a device while you've mapped the letter they use could cause the device to not appear, or could cause your script to start accessing that device instead of your intended share though.

My routine doesn't look for shares, just checks to see if a particular share is already mapped so I can use the existing drive letter and not delete it afterwards. If it's not already mapped, it maps it, then I can delete it afterwards
__________________
Microsoft MVP - Windows Desktop Experience
Of course I know all the answers ; I just don't always match the answers to the right questions
Are you aware of the New Signature Limitations?
scrfix's Avatar
Computer Specs
Senior Member with 269 posts.
 
Join Date: May 2009
Experience: Computer Repair Expert
19-Aug-2009, 10:15 PM #24
I did a net view on my kids laptop.

Code:
Share name  Type  Used as  Comment
-----------------------------------
C           Disk
F           Disk  (UNC)
Public      Disk
Users       Disk
The command completed successfully.
For this test, I had him share
1. The C Drive
2. The F Drive
3. The Users directory.

The external drive is the only one that has used as UNC.
Does this matter? I did not have the drive mapped at the time, nor was I accessing the drive at the time. Could this (UNC) be because it is an external drive or is it something else? If something else, why didn't it show up on the other ones?
__________________
Wayne Leiser, Spectacular Computer Repair Computer Repair, Computer Services
World Famous Gift Baskets: Gift Baskets, Corporate Gifts
Resources LLC: Water Treatment Coagulation, Water Recycling
TheOutcaste's Avatar
Computer Specs
Distinguished Member with 5,485 posts.
 
Join Date: Aug 2007
Location: Oregon, USA
Experience: Intermediate
19-Aug-2009, 10:22 PM #25
The UNC entry is a result of the error with the missing colon. The Used As column shows the drive letter the share is mapped as. Since the colon was missing from the Z, it mapped it as a Universal Naming Convention share.
Use net use \\Matts-laptop\f /delete to remove it.

I have no idea what use it is, as a drive letter is not assigned.
__________________
Microsoft MVP - Windows Desktop Experience
Of course I know all the answers ; I just don't always match the answers to the right questions
Are you aware of the New Signature Limitations?
scrfix's Avatar
Computer Specs
Senior Member with 269 posts.
 
Join Date: May 2009
Experience: Computer Repair Expert
19-Aug-2009, 10:46 PM #26
I ran that command. It said it completed successfully however however it is still there. My main concern was whether it was stating that it was utilizing an external drive as a UNC path. I was hopeful that perhaps this might be a way to distinguish against that.


Off the subject and back onto the original. That link that I provided for the task scheduler I think I have to have python installed because it is asking for files that I have no idea what they are when I attempted to compile the .cpp file they provide.

Thank you for the net use *. I have another program that I use a static drive letter and I would rather not. I am going to look into using that.

Currently, I am manually mapping the external drive letter to Z and then using that static letter in my code. Where I have been running into an issue is when these stupid HP printers utilize Z for their network drive. The office goes and gets one of those all of a sudden my program breaks. I would much rather automate that by using the net use * to determine what letter it is, map the drive to that letter. There is some other items I would have to do for checks and balances but that is ok.
__________________
Wayne Leiser, Spectacular Computer Repair Computer Repair, Computer Services
World Famous Gift Baskets: Gift Baskets, Corporate Gifts
Resources LLC: Water Treatment Coagulation, Water Recycling
TheOutcaste's Avatar
Computer Specs
Distinguished Member with 5,485 posts.
 
Join Date: Aug 2007
Location: Oregon, USA
Experience: Intermediate
19-Aug-2009, 11:22 PM #27
Net Use doesn't care what the drive letter of the drive that contains the share is, it only looks for \\PCname\ShareName. If the drive letter of the external changes, any folders shared will no longer work until they are re-shared.

You can use Net Use to map to a share on the same PC, rather than to a remote system.
Example, you have several PCs, each with an external drive with a folder shared as Backup
You don't know the drive letter of the external, it's different on each PC, but the share name (Backup) is identical.

You can use that routine to map to \\%Computername%\Backup and don't have to know the drive letter of the external, or what drive letters are free, so you can run the same script on all the different PCs.

But if the drive letter of the external changes, the Backup share has to be re-created.
__________________
Microsoft MVP - Windows Desktop Experience
Of course I know all the answers ; I just don't always match the answers to the right questions
Are you aware of the New Signature Limitations?
scrfix's Avatar
Computer Specs
Senior Member with 269 posts.
 
Join Date: May 2009
Experience: Computer Repair Expert
25-Aug-2009, 02:32 AM #28
Jerry,

I am having a little issue with your script. Trying to break it down. I have not attempted to run it yet, merely trying to read it.

If [%4]==[] Goto _Pchk1
Is this because there are parameters that are sent in to the script or are we utiliing %4 as a variable?

I can read some of it but most of it seems cryptic to me currently. I am heading off to bed. I am about to fall over. My son has been sick and up every 30 minutes. It is the wifes shift.

Could I ask you to explain that script in a little more detail. The main part I am trying to take from this other than the obvious being able to read it, is the fact of the net use *. I have attempted this and failed. I am trying to use it in my application where I have an external drive. I plug that external drive in.

I would like to automatically detect what the next available letter is, map that drive to that letter and store that letter into the registry. I have the registry down pat..... my son is up again.... gotta run.
__________________
Wayne Leiser, Spectacular Computer Repair Computer Repair, Computer Services
World Famous Gift Baskets: Gift Baskets, Corporate Gifts
Resources LLC: Water Treatment Coagulation, Water Recycling
Squashman's Avatar
Distinguished Member with 14,983 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: IIAHYAYCESA,YAADA!
25-Aug-2009, 08:58 AM #29
You dont need to know what the next available letter is! That is what net use * does!

crappy forum editor won't let me upper case everything. That has to be the first time I ever tried to upper case anything to get my point across and it wouldn't let me do it. Now I am sad.
__________________
I hate asking the same question twice!
How to ask questions the smart way!
Microsoft MVP - User Desktop Experience

Last edited by Squashman : 25-Aug-2009 09:09 AM.
Squashman's Avatar
Distinguished Member with 14,983 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: IIAHYAYCESA,YAADA!
25-Aug-2009, 09:08 AM #30
Quote:
Originally Posted by scrfix View Post
Jerry,

I am having a little issue with your script. Trying to break it down. I have not attempted to run it yet, merely trying to read it.

If [%4]==[] Goto _Pchk1
Is this because there are parameters that are sent in to the script or are we utiliing %4 as a variable?
Read the usage in the _MapChk script.
Quote:
:: Usage
:: Call :_MapChk "path" rname fname [username password]
:: "path" : Share to be mapped. Must be in quotes
:: rname : This variable will be set to the mapped drive letter
:: fname : Set to 0 if drive already mapped, 1 if a drive was mapped
:: username : Username to be used. Enter * if you wish to use currently logged on user
:: password : Password to use. Enter * if you wish to be prompted
You call that script from another script with variables. Anytime you start a batch file or call a batch with additional parameters the input becomes %1 %2 %3 etc, etc ,etc.....
If you call _MapChk with 5 variables from some other batch file; %4 & %5 are the username and password.
__________________
I hate asking the same question twice!
How to ask questions the smart way!
Microsoft MVP - User Desktop Experience

Last edited by Squashman : 25-Aug-2009 09:13 AM.
Reply Bookmark and Share

Smart Search

Find your solution!



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.

Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 06:46 AM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.
Powered by Cermak Technologies, Inc.