Batch Scripts


  1. Posts : 7
    Windows 7 Ultimate x64
       #1

    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.
    Last edited by arukaen; 27 Oct 2011 at 09:45.
      My Computer


  2. Posts : 31,249
    Windows 11 Pro x64 [Latest Release and Release Preview]
       #2

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

    RUNAS USAGE:

    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
    smartcard.
    /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

    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.
    NOTE: /profile is not compatible with /netonly.
    NOTE: /savecred is not compatible with /smartcard.
      My Computers


  3. Posts : 7
    Windows 7 Ultimate x64
    Thread Starter
       #3

    Where do i insert the runas?

    runas /env /netadmin:netadmin@domain.local "C:\CCFlash\CCFlash.exe"
      My Computer


  4. Posts : 31,249
    Windows 11 Pro x64 [Latest Release and Release Preview]
       #4

    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
    Last edited by Barman58; 27 Oct 2011 at 09:55. Reason: added parameter info
      My Computers


  5. Posts : 7
    Windows 7 Ultimate x64
    Thread Starter
       #5

    Thanks so much!
      My Computer


  6. Posts : 1,814
    XP / Win7 x64 Pro
       #6

    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 Computer


 

  Related Discussions
Our Sites
Site Links
About 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 15:59.
Find Us