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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mapping to server goes away when not logged on.

Status
Not open for further replies.

evergreean43

Technical User
May 25, 2006
165
US
I created Perl script on my Windows 2000 workstation that opens up a mapped directory on a Windows 2000 server. It works great in my task scheduler when I am logged on the workstation.

When I am logged off and the task scheduler executes my script that opens up a mapped directory it doesnt work and fails. Do I lose my mapped directory when I am logged off my workstation?
I assume I only have the mapped directory when I am logged on. If this is the case, anyway to keep my mapping when I am logged off?
 
I may be confused but as long as the drive mapping script works ok when you are logging on, why would you need the mapping to be present when logged off?

Chris Clancy, EnCE
Miles Technologies
 
The script runs on my local workstation task scheduler where it reads a mapped directory on the server at 12:00 Noon everyday. The script has worked everytime I am logged in but on days I am not logged in the task scheduler runs the script and I get an error message in my script saying it could not open mapped server directory.

Please advise because I need the script to work when I am not logged in.
 
Are you running this task as the administrator (or account with similar permissions)?

Chris Clancy, EnCE
Miles Technologies
 
Thanks for quick response.

I am not an administrator and I think I dont have admin account permissions. Do you think the mappings will stay if I had admin permissions???
 
I would contact your local administrator and have them create an administrative account for you to launch this script for you.

Chris Clancy, EnCE
Miles Technologies
 
Use the persistant flag from a command prompt to map the drive instead.

I'm Certifiable, not cert-ified.
It just means my answers are from experience, not a book.
The poster formerly known as lander215
 
Please advise what you mean by persistant flag to my Windows 2000 Server?

Here is how it looks in my Perl Script:

F:\\aa\\bb\\directoryA\\


Here is how I tried it from commmand prompt to test:

\\aa\bb\directoryA\

also tried:

\\\aa\bb\directoryA\



It says "Network path not found
 
add the line at the end of each entry

/persistent=yes

Chris Clancy, EnCE
Miles Technologies
 
I'm not the expert in Perl but would rise a general question: How is the network share mapped to your F: drive, are you mapping it from within your script? If not add the line to your script and everything should work fine.

If the F: drive has been manually mapped and the scheduled task is running under the system account, the mapped F: drive is missing when not logged on with your credentials.

Alternatively change the scheduled task to run with your account information.
 
If you'll logon and map the drive using the net use .... /persistent=yes command, the drive will stay mapped even if you log off.

I'm Certifiable, not cert-ified.
It just means my answers are from experience, not a book.
The poster formerly known as lander215
 
Davetoo, that's correct but only related to the account which executed the net use command. If someone else logs on to your system (like the system account) the mapped drive is not existend and has to be mapped seperately.
 
Thanks,

Lots of great feedback.

Is this the correct way?
Code:
net use \\myservername\aa\bb\directoryA\ /persistent=yes

Then it asks for username and password..Please advise how I enter this?
 
To add the password you need to add /user:domain\user pwd

net use \\myservername\aa\bb\directoryA\ /user:Domain\UserName P@ssw0rd /persistent=yes

 
You can get around this issue by locking your system instead of logging off.

Using the persistent flag will not resolve the issue, it will only ensure that the drive gets remapped when you next log on. The persistance is for the mapping, not the connection. A drive mapping is dependent on a user session.

Another option would be to try using a UNC path in your script instead of a drive letter. However, as you mention you do not have admin access to the workstation, I doubt that would succeed.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
Providing the user name and password is an option as basst mentioned but will leave this information in your sctipt in clear text. If anybody opens the script he has all information he needs...

If you need special permissions to map the network drive, an alternative option is to change the credentials for the task.

Go to the Task Scheduler, choose the properties of your task and change the 'Run as' value to run the task with i.e. your account information. When executing the task it will start with your credentials and user rights - using the 'net use' command in your script will map the drive, using the 'run as' function for the scheduled task will ensure the user rights for mapping the drive.

The only downside for this scenario - if you change your account password, you manually have to change the password within the task otherwise the task will fail to start.
 
Thanks the script now works in the scheduler when I am logged off.

I did this in my dos prompt to set my net use mapping:

Code:
net use \\myservername\aa\bb\directoryA

This allowed me to call it like this in my Perl script:

\\\\myservername\aa\bb\directoryA\


I have logged out and rebooted my workstation and executed the script on task scheduler when I am not logged on and it works great.


I could not get the below to work doing this because it said I didnt use correct syntax.
Code:
net use \\myservername\aa\bb\directoryA\ /persistent=yes
I didnt want to use username password which I assume I would need to get to work.


My question is if I dont use persistent=yes will I lose my connection in the future or what will happen?

 
I found that the UNC path is what I had:

\\\\myservername\aa\bb\directoryA\


And I assume I could have used that all along to get this to work because this is what I found on google:


"Rather than describe the location of a file or directory by drive letter, the Network Group will typically communicate a UNC path to describe the actual location of a file or directory. Windows drive letter mappings are arbitrary, whereas a UNC path is specific and applies to all operating systems."

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top