?
Solved

Adding Runas to a batch file

Posted on 2006-05-24
7
Medium Priority
?
1,267 Views
Last Modified: 2008-01-09
Hi,

I am creating a batch file to email to domain users; the file will copy a file from a network location to "C:\Program Files\App_Directory".
As our standard domain users do not have the "Write" permission to the directories bellow "C:\Program Files" I want to include the "Runas" command to use admin credentials.

Please can someone tell me the syntax for this and were to include this is the following batch script:
Thanks  


#######################################################################################
echo off
cls
title Copy ZetaFax.dot
color f0
copy "C:\Program Files\Zetafax\zetafax.dot" "C:\Program Files\Microsoft Office\OFFICE11\STARTUP"
Exit
#######################################################################################
0
Comment
Question by:Nael_Shahid
  • 4
  • 3
7 Comments
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 16749811
Hi Nael_Shahid,


The runas command will require a password. This will need to be entered. At that time, the user will either need to know it or someone has to do it for them. In which case the person typing it may as well simply copy the file themselves.

Alternatively, you could use the C$ shares to push the file onto their computer.

Regards,

Richard Quadling.
0
 

Author Comment

by:Nael_Shahid
ID: 16749821
Richard,

Can I not include the password within the script..?

I understand this is a security issue; however I will include the command to delete the batch file once it has run.

Cheers
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 16749827
By the looks of it, no ...

RUNAS USAGE:

RUNAS [ [/noprofile | /profile] [/env] [/netonly] ]
        /user:<UserName> program

RUNAS [ [/noprofile | /profile] [/env] [/netonly] ]
        /smartcard [/user:<UserName>] program

   /noprofile        specifies that the user's profile should not be loaded.
                     This causes the application to load more quickly, but
                     can cause some applications to malfunction.
   /profile          specifies that the user's profile should be loaded.
                     This is the default.
   /env              to use current environment instead of user's.
   /netonly          use if the credentials specified are for remote
                     access only.
   /savecred         to use credentials previously saved by the user.
                     This option is not available on Windows XP Home Edition
                     and will be ignored.
   /smartcard        use if the credentials are to be supplied from a
                     smartcard.
   /user             <UserName> should be in form USER@DOMAIN or DOMAIN\USER
   program         command line for EXE.  See below for examples

Examples:
> runas /noprofile /user:mymachine\administrator cmd
> runas /profile /env /user:mydomain\admin "mmc %windir%\system32\dsa.msc"
> runas /env /user:user@domain.microsoft.com "notepad \"my file.txt\""

NOTE:  Enter user's password only when prompted. <<<<<<<<<<<<<<<<<< IMPORTANT PART
NOTE:  USER@DOMAIN is not compatible with /netonly.
NOTE:  /profile is not compatible with /netonly.
0
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!

 
LVL 40

Accepted Solution

by:
Richard Quadling earned 375 total points
ID: 16749834
Use something like a policy or a logon script or something else for this.
0
 

Author Comment

by:Nael_Shahid
ID: 16749843
If I add this to a startup script through a GPO which account permissions will be used..?
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 16749869
Not sure.SOrry.
0
 

Author Comment

by:Nael_Shahid
ID: 16749874
ok, thanks
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Introduction Often we come across situations wherein our batch files would be needing to reboot Windows for a variety of reasons. A few of them would be like: (1) Setup files have been updated whose changes can take effect only after a reboot …
As the title indicates, I have done this before. It chills me everytime I update the OS on my phone, (http://www.experts-exchange.com/articles/18084/Upgrading-to-Android-5-0-Lollipop.html) because one time I did this and I essentially had a bricked …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Suggested Courses

839 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