Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


RUNAS error - windows 7 PC running batch script via unc

Posted on 2011-03-17
Medium Priority
Last Modified: 2012-05-11
I have a Windows 7 PC where the user opens a batch file from a mapped drive which then calls a script via a unc path using the runas command to elevate privileges.  This works from an XP machine but not from a Windows 7 machine.

For example the first script on the mapped drive is as follows:

runas /user:scs\chrismanbup \\\manual_backup\test.bat

The user then keys the password for the chrismanbup account and we get the below error from the Windows 7 machine:

Attempting to start \\\manual_backup\test.bat as user "scs\chrismanbup" ...
RUNAS ERROR: Unable to run - \\\manual_backup\test.bat
299: Only part of a ReadProcessMemory or WriteProcessMemory request was completed.

The user is not an administrator but if I use "Run as administrator" it still gives the same error. As mentioned if I run from an XP machine as the same user it runs.

Any ideas?
Question by:scs-paul
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
  • 6
  • 3

Expert Comment

ID: 35163764

Are you trying with 64-bit or 32-bit Windows 7? What is the script trying to do?

Author Comment

ID: 35164590
This is 32bit Windows 7.  The script does the above - it calls a second script on another server using elevated privileges. The script fails with the aforementioned-mentioned error and does not start the second script.
LVL 71

Expert Comment

ID: 35176430
It might be because the mapped drive is not available to the other user in runas, so while trying to start the command the working dir is removed. For test, try if running the script locally helps.
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 35176858
I can map the drive as the user in the runas script from an XP machine but not from a Windows 7 machine. This occurs whether UAC is on or off.
LVL 71

Expert Comment

ID: 35177130
How do you try to map the drive? Can you map it outside of the runas script as that user?

Author Comment

ID: 35177342
No I cannot map the drive from Windows 7 as the user in the runas script from windows explorer menu but I can do so from an XP machine.
LVL 71

Expert Comment

ID: 35177364
Hmm. But you can see the server's share on the W7 PC if you just type   \\servername   in Explorer?

Author Comment

ID: 35177600
Tried mapping the share on another Windows 7 machine and it could map as the runas user which was not working on the other Windows 7 machine this morning. Tried again on the original machine  and it is now mapping the share as the runas user.
This has not solved the error when using the first script to call to this share and run the batch file and I assume this is to do with UNC paths and added security to Win7.
I need to use the first script to call the second script with the elevated privileges as the second script deletes/moves some directories and then stops a service on the machine, copies some files and then restarts the service - so needs to run as an administrator.
Mapping the drive on the windows 7 PC and then right clicking the second script batch file (while holding shift) and using "run as different user" and using the RUNAS user from the script has the same error as running the first script to call the second script.


Accepted Solution

scs-paul earned 0 total points
ID: 35204674
This was solved by using the runas /netonly switch.

Author Closing Comment

ID: 35230181
Eventually solved this issue by using the /netonly switch in the runas command line.

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Assume you have an outside contractor who comes in seasonally or once a week to do some work in your office, but you only want to give him access to the programs and files he needs and keep all other documents and programs private. Can you do this o…
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This Micro Tutorial will teach you the basics of configuring your computer to improve its speed. It will also teach you how to disable programs that are running in the background simultaneously. This will be demonstrated using Windows 7 operating…
Suggested Courses

705 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