Adding Runas to a batch file

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
#######################################################################################
Nael_ShahidAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

 
Richard QuadlingSenior Software DeveloperCommented:
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
 
Nael_ShahidAuthor Commented:
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
 
Richard QuadlingSenior Software DeveloperCommented:
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
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
Richard QuadlingSenior Software DeveloperCommented:
Use something like a policy or a logon script or something else for this.
0

Experts Exchange Solution brought to you by ConnectWise

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
 
Nael_ShahidAuthor Commented:
If I add this to a startup script through a GPO which account permissions will be used..?
0
 
Richard QuadlingSenior Software DeveloperCommented:
Not sure.SOrry.
0
 
Nael_ShahidAuthor Commented:
ok, thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.