Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DOS Bat File Need Help 3

Status
Not open for further replies.

lizI3

Programmer
Jul 2, 2002
31
CA
I am running on a network and and when we sign on to the computer we automaticlly connect to our P:\ database\ drive. I wanted to create a .bat file that would run to check to see if we were connected and if not actually map the connnection for the user. How would I do this? I thought of using the If not exist P:\database\ but am not sure how to tell to connect Can anyone help

thanks Liz
 
You want the "net use" command. It's been a LONG time, so forgive me if I'm wrong, but your command would look something like:

Code:
     net use p: \\computer\direcotry /yes

You should be able to type:

Code:
     "net use /? | more"

from a DOS prompt to get the proper syntax.

Hope this helps,
sshowers
 
Any idea how you would re-map a drive using a similar method, I'm having a problem where my users all have their drives mapped under different letters. This causes my databases to generate errors when I link or refer to other databases from within code.

Thanks

Craig
 
Net use just tells me what is connected and what is not.
I don't know the command to connect if it is not already connected. In windows exployer you would go tools - Map Network drives in the drive box you would pick P in the folder you would select I3 asi-001 etc I don't know how to do this in DOS?

grobermatic I am pretty new at all of this but My VB teacher talked about app path in the VB code rather than specifing a particular drive.


Liz

 
Is there a way then to refer to a database, or any file for that matter, on a particular drive without actually referring to the drive letter?

If I link to a database which resides on drive F: (for me) and another user has the same drive but with letter G: they cannot access it, even though they can go to drive G: and open it they can't open the linked DB because it has hardcoded a reference to the drive letter F: when I designed it.

Liz, your post about dealing with drive mapping in DOS seemed to give me a new avenue to check out, I still feel this may be the solution.

I'm sure there is a solution to this but I'm yet to find anyone who is experiencing the same problem.

Any further ideas would be appreciated

Craig
 
From a DOS prompt (or a .bat file) the 'net use' command will map, or re-map, a drive. For example, in my environment I have a server named 'vader' and another named 'skywalker'. If I type:

Code:
     net use p: \\vader\market /yes

From Windows explorer I will see the newly mapped 'P:' drive pointing to the 'Market' directory on server 'vader'. If I subsequently type:

Code:
     net use p: \\skywalker\it /yes

Windows explorer will now show the 'P:' drive as being re-mapped to the 'IT' directory on server 'skywalker'. I could also have typed:

Code:
     net use p: /delete /yes
Code:
     net use p: \\skywalker\it /yes

This would have achieved the same result. Typing 'net use' in a DOS prompt with no other options or parameters shows you your current network mapping. The 'net use' command is, actually, a subset of the (rather powerful) 'net' command.

You should always check with your network administrator to make sure you're not violating administrative policy by mapping or re-mapping drives...

--sshowers
 
As long as you're not using Novell NetWare mapped drives, you can use the UNC (the \\COMPUTERNAME\folder\folder type address) itself when opening a database. All you need to know is the computer name and folder, and you can bypass any and all mapped drives. For example, a shortcut would be:
"C:\Program Files\Microsoft Office\Office\MSACCESS.EXE" "\\COMPUTERNAME\FOLDER1\SUBFOLDER\ETC\db1.mdb"

This also works for linked tables and pretty much anything else you can think of pertaining to Access.



This way you can avoid meddlesome "net use" commands.
 
As a developer and/or consultant, however, the meddlesome "net" (and "subst") commands are nice to know because you can map a drive that configures your development system to mimic the client's production system without having to reset UNC resource names.

--sshowers
 
You can try this wherever you are refering to the path.

Dim WrkDrv As String
Dim Path As String
Dim mylen As Integer
Dim filelength As Integer
Path = CurrentDb.Name
filelength = Len(CurrentProject.Name)
mylen = Len(Path) - filelength
WrkDrv = Left(Path, mylen)

This should give you the exact path that the database is running from.

Hope this helps.
 
liz, you are in the same thing I'm in it seems. We have over 350 servers here and most people are connected to at least 10-15 that they use all the time.

I have linked graphics in some field reports, and the ImagePath HAD to include the server letter. (Drive Q:) If someone maps to the database using a seperate drive, everything will work fine till they try to run certain reports, then BAM! Error, cant find xxxxx.jpg....I've never found a way around it except for remapping everyone to drive Q:....it was easy for me because there are only 35 people that use my db....
 
Hi Everyone

I found, totally by accident, that you can use the IF NOT EXIST batch command to check and see if a mapping exists from within a batch file, then recreate it if not.

For example on Microsoft networks:
IF NOT EXIST Q:\NUL NET USE Q: \\SERVER\SHARE

or if Novell:
IF NOT EXIST Q:\NUL MAP ROOT Q: \\SERVER\VOL1\DIRNAME

If there is no drive Q:, it will then remap it to the appropriate directory. I have found that you can use the NET USE command to create mappings to Novell shares, but only at the top level, and of course this would be a volume, so becomes a security risk as it lets users easily snoop around areas they shouldn't be able to but if access rights are configured correctly, it shouldn't be much of a problem.
I have found, however, that there is no problem using UNC names for Novell shares, provided that the computer has the full Novell client32 installed - rather than the Microsoft client for Netware.

Hope that this helps everyone here.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top