You are not logged in.

#1 20 Aug 2007 01:05

NDog
Member
From: New Zealand
Registered: 31 May 2006
Posts: 121
Website

script to run all exes in a folder

Hey guys. I am trying to write a simple script that can run all the exe files in this ms update folder I have

@echo off
title MS Updates
setlocal enabledelayedexpansion

ECHO.
ECHO Update Files
set counta=1
for /f "usebackq tokens=*" %%g in ('dir /b "*.exe"') do (
    set _update!counta!=%%~g
    set /a counta+=1
    "%cd%\%%g" /norestart /passive 2>nul >nul
    )

What am I doing wrong here. Thanks


cmd, vbs, ps, bash
autoit, python, swift

Offline

#2 20 Aug 2007 18:17

Simon Sheppard
Admin
Registered: 27 Aug 2005
Posts: 1,130
Website

Re: script to run all exes in a folder

Whats the actual error?

if you change the last line to

ECHO "%cd%\%%g" /norestart /passive

What do you see?

Offline

#3 25 Aug 2007 07:05

NDog
Member
From: New Zealand
Registered: 31 May 2006
Posts: 121
Website

Re: script to run all exes in a folder

Hey Simon

I fixed it by changing the code . I am just curious about the whole usebackq syntax, sometimes it is not neccesary

@echo off
title MS Updates
setlocal enabledelayedexpansion

ECHO.
ECHO Update Files
set counta=1
for /f "tokens=*" %%g in ('dir /b "*.exe"') do (
    set _update!counta!=%%~g
    set /a counta+=1
    echo %%g
    "%cd%\%%g" /norestart /passive 2>nul >nul
    )

Last edited by NDog (25 Aug 2007 07:07)


cmd, vbs, ps, bash
autoit, python, swift

Offline

#4 03 Sep 2007 12:12

bluesxman
Member
From: UK
Registered: 29 Dec 2006
Posts: 1,129

Re: script to run all exes in a folder

It certainly has its place and is most useful when you want to specify multiple input files (where the paths contain one or more spaces) as your "file-set".

The reason your initial script didn't work was because you used normal quotes ' instead of back quotes ` on your DIR command.

Last edited by bluesxman (03 Sep 2007 12:13)


cmd | *sh | ruby | chef

Offline

Board footer

Powered by