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 10 Pro x64 x3, Ubuntu

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 10 Pro x64 x3, Ubuntu

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
Thread Forum
InstallShield LE & SQL Scripts
I'm supposed to create an installer for a program for my TAFE course. The program needs a DB to work. I got the short straw and drew the junky InstallSheld LE. :sick: Other students got the even worse ClickOnce (it has failed to create an installer every time I've tried it). :mad: Only...
How to run a batch file at logoff & some batch scripting help please
Hiya, I'd just like to run a simple batch file at logoff to backup some settings. I plan to use Robocopy, which is what i use to more thorough backups. Two questions: 1. How make it run by clicking Start > Shutdown? (i realise i could make a shutdown batch file and run it instead, but i'd...
Backup and Restore
Two Scripts: START then END Application
I'm running low on resources and am not wanting to upgrade, so it looks like a script to the rescue! Basically I work with Oracle 11g on my computer. Here are the 2 scripts that I'm looking to do. Please help. Thanks. Script 1: Start Oracle 11g START Service A START Service B START...
General Discussion
message about scripts on bootup?
Hi this is probably not a windows 7 problem but has only arisen since I changed from Vista, when I switch on and log in , as soon as my desktop appears I get a message (attached) can't seem to get rid of it, maybe I'm missing something obvious here?:confused:
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 04:40.
Twitter Facebook Google+ Seven Forums iOS App Seven Forums Android App