Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

Windows 7: Batch Scripts

27 Oct 2011   #1

Windows 7 Ultimate x64
Batch Scripts

I am trying to run/create a batch script for the users on my domain to install a program that will download and update flash and java. I have the .exe stored on the network share and currently have most of the script written. The part where i need help is to have to .exe run as one of our network administrators. Below is the code I have, where/how do I tell it to run as domain.local\networkadmin plus the account's password.

@echo off
cd C:\
mkdir CCFlash
copy \\toohey\CareCloud\CCFlash.exe C:\CCFlash
START C:\CCFlash\CCFlash.exe /silent S:\IT\CCFlashReports\reports.txt /repair

All help is appreciated.

EDIT: This script will run on XP Pro and Windows 7 Pro machines. 32 and 64 bit.

My System SpecsSystem Spec

27 Oct 2011   #2

Windows 8.1 x64 x3 + Windows 10 Preview

Take a look at the runas command, it should give you what you need


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

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

RUNAS /trustlevel:<TrustLevel> 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 7 Home or Windows 7
Starter Editions
and will be ignored.
/smartcard use if the credentials are to be supplied from a
/user <UserName> should be in form USER@DOMAIN or DOMAIN\USER
/showtrustlevels displays the trust levels that can be used as arguments
to /trustlevel.
/trustlevel <Level> should be one of levels enumerated
in /showtrustlevels.
program command line for EXE. See below for examples

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

NOTE: Enter user's password only when prompted.
NOTE: /profile is not compatible with /netonly.
NOTE: /savecred is not compatible with /smartcard.
My System SpecsSystem Spec
27 Oct 2011   #3

Windows 7 Ultimate x64

Where do i insert the runas?

runas /env /netadmin:netadmin@domain.local "C:\CCFlash\CCFlash.exe"
My System SpecsSystem Spec

27 Oct 2011   #4

Windows 8.1 x64 x3 + Windows 10 Preview

Sorry for confusion - the runas is a replacement for the regular start command

you should also be able to add the parameters from you start instruction in you original script, but you may need to "play" with the quotes to get it to accept them
My System SpecsSystem Spec
27 Oct 2011   #5

Windows 7 Ultimate x64

Thanks so much!
My System SpecsSystem Spec
27 Oct 2011   #6

XP / Win7 x64 Pro

You do realize you're going to need to either hardcode the domain admin password into that file (not smart) or have to type it in at runtime, right?
My System SpecsSystem Spec

 Batch Scripts

Thread Tools

Similar help and support threads for2: Batch Scripts
Thread Forum
Solved How to run a batch file at logoff & some batch scripting help please Backup and Restore
IE9 prompts to run scripts or activex Browsers & Mail
Two Scripts: START then END Application General Discussion
Windows Startup scripts.. exactly when? General Discussion
User scripts Browsers & Mail
message about scripts on bootup? General Discussion

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 03:09 PM.
Twitter Facebook Google+

Windows 7 Forums

Seven Forums Android App Seven Forums IOS App

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33