Over 1 million tech questions and answers.

Solved: Output log file from PSExec batch

Q: Solved: Output log file from PSExec batch

I have created a couple batch files to easily update firefox on users computers. See the scripts below.

This executes a batch file on all computers listed in the firefoxusers.txt file.
Code:
psexec @firefoxusers.txt -u [I]AdminUsername[/I] -p [I]password[/I] c:\installers\firefox.bat
This is the file that is executed from the one above to install the file silently from a shared drive.
Code:
pushd \\server\applications\firefox

firefoxsetup.exe -ms

popd
My problem is that when I run this script I have no idea if the software was installed correctly or not. I am looking for a way to just output what was run so I can go through and see if anything failed.

Any help would be appreciated.

Thanks

RELEVANCY SCORE 200
Preferred Solution: Solved: Output log file from PSExec batch

I recommend downloading and running Reimage. It's a computer repair tool that has been proven to identify and fix many Windows problems with a high level of success.

I've used it in the past to identify and fix everything from blue screens (BSOD's), ActiveX errors, corrupt files and processes, dll/exe/sys errors, recover lost memory, Windows update problems, defragging, malware removal etc.

You can download it direct from this link http://downloadreimage.com/download.php. (This link will automatically start a download of Reimage that you can save to your computer.)

A: Solved: Output log file from PSExec batch

Not sure if Redirection will work or not.
http://www.robvanderwoude.com/redirection.php

You could try this.
psexec @firefoxusers.txt -u AdminUsername -p password c:\installers\firefox.bat 2> errorlog.txt

or inside your batch file. Not sure if this one witll work or not.
firefoxsetup.exe -ms 2> \\server\applications\firefox\errorlog.txt

Read other 2 answers
RELEVANCY SCORE 85.6

Ok imma give a full rundown of the situation. Currently on the network we are on because of the way it is setup wake on lan doesn't work, so SCCM has at best a 70 success rate for patching. So I am currently spending a couple days a week remoting into computers and running a batch file to manually update computers. I need a way, that isn't psexec to execute a batch file on a remote computer. If anyone has any ideas they would be greatly appreciated.

Additional Notes
- Batch file is on share drive atm.

A:Run Batch File On Remote Computer Without PsExec

So, you are using RDP and remotely logging into the computer? If that's the case, you should be able to put the batch file on a network share, and then execute it while you are in the RDP session.

Read other 9 answers
RELEVANCY SCORE 78.8

Hi,
I'm trying to write a batch file to do some basic file copy/folder management tasks.

What I want to do is create a directory with the current date in the format yy-mm-dd.

Since I have php installed, I can run

Code:
php -r echo(date('y-m-d'));
But I want to use the output of this as the parameter of mkdir. Is there any way of doing this?

Thanks.
 

A:Solved: Batch file command output redirection

I Don't Know PHP . But Here Is How to Make A Folder With Todays Date

MD %DATE:~4,2%-%DATE:~7,2%-%DATE:~10,4%

%DATE% - expands to current date using same format as DATE command.

%var_:~Start,Count% where the Start commences at 0
 

Read other 2 answers
RELEVANCY SCORE 69.2

Not sure if this would be the right forum to post this in... but I suppose it doesn't fit in any other forum anyways.

So I have a batch file I'm TRYING to write to do basically one thing:
Determine if a device is disabled.

I've gotten the command to give me a status output of the device, however, I can't seem to get the IF statement to work properly.

I figure I must set the output of the status thing to a variable, and then try and tell the thing to see if the word 'disabled' is in the variable string.
I've got this so far:

:TOP
FOR /F "tokens=*" %R IN ('devcon status ACPI\WACF009') DO SET VAR=%R
IF %VAR% == "*disabled*"
ECHO Device Disabled!!!
GOTO TOP

I'm apparently bad at this whole batch file writing thing, and I keep making mistakes, so I thought I'd see if anyone here knows anything.
In case you're wondering... No, I'm not trying to be redundant. In the end, the batch file is actually going to toggle the state of my notebook's WACOM sensor... the ECHO will eventually be replaced by the command to re-enable the touch sensor.
 

Read other answers
RELEVANCY SCORE 69.2

I wrote a batch file to output my system infor to a txt file.
After I run it, I found that the fonts are not the same.
The output for "wmic" obviously are different than others (See attachment).
There is also a big gap for CPU infor. I tried to delete the "echo." but no luck.
However, while I run "wmic" alone, its output is normal. but while I put some commands before "wmic", the fonts look wired.
anyone know why? thanks!
Here is my code:
@echo off
echo Checking your system infor, Please wating...
systeminfo | findstr /c:"Host Name"
systeminfo | findstr /c:"Domain"
systeminfo | findstr /c:"OS Name"
systeminfo | findstr /c:"OS Version"
systeminfo | findstr /c:"System Manufacturer"
systeminfo | findstr /c:"System Model"
systeminfo | findstr /c:"System type"
systeminfo | findstr /c:"Total Physical Memory"

ipconfig | findstr /c:"IP Address"

echo.

echo Hard Drive Space:
wmic diskdrive get size

echo.
echo.

echo Service Tag:
wmic bios get serialnumber

echo.
echo.
echo CPU:
wmic cpu get name

echo Completed! Thank you!

pause

A:after batch file output to txt, the font not consistent?

Yeah, so I tried it myself and I didn't have any issues.

If you want your system Information, download an awesome little app called Speccy from Piriform (Piriform - Download CCleaner, Defraggler, Recuva, Speccy - Millions of users worldwide!). It pulls from the hardware itself, not just what Windows thinks it is.

Read other 6 answers
RELEVANCY SCORE 68.4

I'm not a script expert but I'm trying to right something simple (or so I believe).

I want to run a command in a batch file: systeminfo

This command returns a lot of information.

I want to be able to extract two lines and place their content into variables, more specifically, "Host Name" and "System Up Time". Than I would write them to a file (as if it was a log). I already got something similar doing the following:

systeminfo | find /i "Host Name" >> text.txt
systeminfo | find /i "System Up Time" >> text.txt


The problem is that this only creates a string that I can't treat. I would like the "System Up Time" to be broken into hours, minutes and seconds (or translated into seconds) because I want to add a statement that if the "system up time" is less than 10 minutes, then do something.

Is this possible?
Is there any other command that I can use?
Any help is appreciated.

Read other answers
RELEVANCY SCORE 64.4

If someone can Please help, I just need the Data in the XML tag extracted to Batch File Variable....the rest i figured out and works great for the backup...just need the extracted tags...
thank you

i have a parent directory that contains a sub directory and a XML file that i need a batch to read 2 specific tags then create a Set command in the batch with those 2 lines to create a backup folder with the tags as the names and such. looks like this:

Parent Directory = XML
XML Folder contains > WJFKB02229001.D Folder & Config.xml File

I need to read the contents of the xml "Config.xml" extract the PhaseID Tag data "WJFKB02229001"
Also need to extract the BoxID "D", I don't need anything else on these seperate lines.

keep trying the following For /F command but no luck
Code:
[COLOR=red]for /f "tokens=1 delims=[" %%G in ("PHASEID" %path%\%myfile%) DO ([/COLOR]
[COLOR=red]set PhaseID=%%G[/COLOR]
[COLOR=red])[/COLOR]
[COLOR=red]echo Phase: %PhaseID%[/COLOR]
pause

and i've searched so many sites and forums with no real help on this one....the data is contained in the xml, weird enough i guess that it's enclosed in brackets "[", which all the forums i read and try it either replies with a blank variable being passed or says it can't find the file at all....

PLEASE HELP, lol

Code:

:StartSet
Set PhaseID="[COLOR=red][B][I]Extracted PhaseID from xml[/I][/B][/COLOR]"
Set BoxID="... Read more

A:Solved: Batch File Extract TAGID to Batch Variable? weird

Read other 16 answers
RELEVANCY SCORE 60

Ok I'm totally at a loss on how to word this so I'm just going to write it out the best that I can...

First I have a batch file that I'm writing that will convert mp4 files to mp3 files (I have a lot) for a buddies band using ffmpeg.

Here's the code that I'm using:

ffmpeg -i folder\video.mp4 -f mp3 -ab 160000 -vn "\different folder\music.mp3"

what I would like to do is add to this so that I don't have to write out this code for every file I have... :/

I have the mp4 files in one folder and than the mp3 files are saving to another folder.

So here's an example of what the code will do if it isn't clear yet.

Folder 1:

video1.mp4
video2.mp4
video3.mp4

what it should do is grab video1.mp4 and convert it.

ffmpeg -i folder\video1.mp4 -f mp3 -ab 160000 -vn "\different folder\music1.mp3"

and than move onto the next one

ffmpeg -i folder\video2.mp4 -f mp3 -ab 160000 -vn "\different folder\music2.mp3"

and than the next one

ffmpeg -i folder\video3.mp4 -f mp3 -ab 160000 -vn "\different folder\music3.mp3"

It's going to have to grab the name from the mp4 file and insert it for the mp3 file.

I can get around pretty good in cmd if it's basic commands but when it comes to something like this I'm a little confused...

Thanks for the help in advance!
I'll see what i can do about searching some more on what I would have to do and if I find the solution I'll post it here if it isn't already answered.

A:Batch File that grabs file names from folder to insert into batch file

A DOS "for /f" loop should do the trick, although changing the filename extension for the output to do everything in one line escapes me at the moment.

Perhaps you could do a dir .\folder\*.mp4/s/b > mp4s.txt, then make a copy of that and edit each line to rename the file to the destination name, and save it as mp3s.txt. Then you just feed both the source (mp4s.txt) and destination (mp3s.txt) filesnames into the for /f loop which handles the ffmpeg conversion.

Quite a crude solution and you'd have to handpatch the destination filenames, but i can't think of how to get a source mp4 filename and then just change the extension.

Read other 3 answers
RELEVANCY SCORE 59.2

Hi,
I have a question  that how to copy file from remote desktop user drive to my local machine using  xcopy or any other protocol.

This is my server path "\\Trail01" and here is the file location "c:\Users\ashique.sheikh\Desktop\Day2.R"
How can i give this is in my batch file. I have used this
net use "\\Trail01" "[email protected]" "/USER:ashique.sheikh"
XCOPY /Y \\Trail01\c:\users\ashique.sheikh\Desktop\Day2.R  "D:\VMI"
But its not working. It is give path error.
How can i download this or is there any other way to do it?

Read other answers
RELEVANCY SCORE 56.8

I am trying to write a batch program the list the current directory files that end in *.dwg
into a file on my C drive.
I have used the following code:
dir *.dwg /b >C:FileListing.txt
start notepad C:FileListing.txt

This code only gives file names in the current directory.
I need to have a list of path and file names in the file FileListing.txt
Is there a way to do that without including subdirectories??

Thank you,
 

A:Solved: Batch file to list file names in current Folder.

Read other 9 answers
RELEVANCY SCORE 56.8

I created this batch file to log certain users logins. It creates a text file to log in, but doesn't populate any of the data to it. Could someone please take a look at it and see what I did wrong. I'm new to writing batch files.

Thanks in advance. Here is the code.

@echo off
set target=JDoe
if %username% == target echo %username% %date% %time% %computername% >> c:\logfile.txt
 

A:Solved: Batch file creates text file but does not populate data to it

target is a variable. You have to surrournd it with %% like any other variable.
Code:

C:\>set target=Squashman

C:\>if %username% == %target% echo %username% %date% %time% %computername% >> c:
\logfile.txt

C:\>type logfile.txt
Squashman Fri 05/23/2008 10:34:14.74 BUMBLE-BEE

C:\>

 

Read other 3 answers
RELEVANCY SCORE 56.8

More as an alternative to twiddling my thumbs than anything else, I tried to produce a batch file that would count up the number and size of files in a folder, as well as the number and size of files with each extension. Hence it would say how many word documents I have and how much space they're taking up, etc.

I've managed to get a vaguely working model, but the output formatting is terrible (I just wanted it to say X bytes in Y "Z" Files, none of that ugly dotted variable names) and I have failed to get it to equate .htm and .html, .jpg and .jpeg, etc.
Code:
@ECHO OFF
REM THIS BATCH FILE ITTERATES THROUGH ALL THE SUBFOLDERS AND FILES IN A FOLDER (IDEALLY A DRIVE)
REM IT TOTALS THE NUMBER OF FILES CONTAINED IN THAT FOLDER, AND THE SIZE OF THOSE FILES.
REM IT ALSO TOTALS THE NUMBER AND SIZE OF FILES WITH EACH EXTENSION IT ENCOUNTERS.
REM ALL INFORMATION IS THEN PRINTED TO THE SCREEN AND FTYPEDST.TXT

IF EXIST FTypeDst.txt ERASE FTypeDst.txt
ECHO. >FTypeDst.txt
ATTRIB +A FTypeDst.txt

ECHO SCANNING FILE TREE FOR FILE EXTENSION DISTRIBUTION
ECHO Please Wait Paitently. . .

(SET /A ALLNUMBER = 0) & (SET /A ALLSIZE = 0)

REM cycle through the current directory and subs, Increment Allnumber, Allsize, define and increment Number of * files, size of * files.
FOR /R %%F in (*) DO (
SET /A ALLNUMBER += 1
SET /A ALLSIZE += %%~ZF
IF NOT DEFINED Number.of.%%~XF.files (SET /A Number.of.%%~XF.files = 0)
IF NOT DEFINED Size.of.%%~XF.files (SET /A Size.of.%%~X... Read more

A:Solved: File Type Distribution analysis: Batch File.

Posted via Mobile Device
You would be better off using third party software that already does this. Plenty of them out there.
I personally would check the extension of each file using the cmd extensions of a for loop. then do an if statement for each file type you want to keep track of. then use a call statement to branch to a function that adds up the file sizes and number of files.
 

Read other 3 answers
RELEVANCY SCORE 56.8

Hi . I'm making a "PC TuneUp" project , but something is wrong . When the batch file tries to check for updates , it closes . Fortunately , i know that it closes because it doesn't find the file . But i tried everything - nothing worked . Please help !
Code:

@echo off
for /F "tokens=1" %%G in ('tasklist /V /NH /FO TABLE /FI "WINDOWTITLE eq TehDansorz"') do IF %%G==cmd.exe exit /b
if exist newest%winver%pctuneup.ver del newest%winver%pctuneup.ver
if exist %winver%pctuneup.ver del %winver%pctuneup.ver
set winver=Win7+WinVista
set ver=1.6a
set title=title TehDansorz's PC TuneUp for Win7/WinVista Version %ver%
title Requesting admin permissions ...

:: BatchGotAdmin
::-------------------------------------
REM --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"

REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Administrator privileges are required for this app to work .
echo Please click OK in the following screen .
PING 1.1.1.1 -n 1 -w 600 >NUL
goto UACPrompt
) else ( goto gotAdmin )

:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"

"%temp%\getadmin.vbs"
exit /B

:gotAdmin
title Got a... Read more

A:Solved: Batch file closes when downloading version file

Read other 7 answers
RELEVANCY SCORE 56.8

Hi,

I have a file in a folder on a network drive whose path is : "\\sql\imp\ssis"

I need a windows batch file that looks into the above folder for a file with a name like : "abcd_03052012_84373.txt" .

The above file name has a date embedded in it in "ddmmyyyy" format. I want that to be extracted and put into a variable or a file somewhere so that I can read that later and store into a sql table.

Please help.
 

A:Solved: Extract Date from File Name - Using Windows Batch File

Read other 6 answers
RELEVANCY SCORE 56

Alright, so what I'm trying to do is list all the shortcuts & folders in the start menu and list all the shortcuts & folders on the desktop and put this into a text file. The reason is to get a full list of programs our teachers use before we re-image their machine and not all of their programs are listed in add/remove programs and not all programs make a folder in Program Files, that is why I'm trying to do it in this roundabout way. What I have so far is this:

@echo off
mkdir "p:\Program List"
DIR "c:\documents and settings\all users\start menu\*" /S/B/OD > "p:\Program List\%computername% Start Menu.txt"
DIR "c:\documents and settings\all users\desktop\*" /S/B/OD > "p:\Program List\%computername% Desktop.txt"

This works perfectly but the only problem is the file has these:
c:\documents and settings\all users\start menu\
c:\documents and settings\all users\desktop\

before each entry in the text file. Is there an easy way to remove these lines so the text files are easier to read? I've checked other sources and can't figure out how to get this to work...

A:[SOLVED] Delete text from .txt file in a batch file

Open the files in Notepad, click Edit, then replace, and enter the string C:\Documents and Settings\All Users\ and replace it with nothing (no entry).

:)

Read other 10 answers
RELEVANCY SCORE 56

I am wondering how to write a script that would delete all files of a certain extension from a folder.
 

A:Solved: Batch file to delete all .xxx files from a file

Read other 6 answers
RELEVANCY SCORE 55.2

Hi all, I need to change the name of a file that I am FTP'ing each day automatically. I'm not very good with batch files but here is my code.

@echo off
G:
cd "G:\nmc\Business Operations\Development\Earned Revenue Report"
> script.ftp echo stpan
>>script.ftp echo krtssss
>>script.ftp echo cd /home/users/ftprpts
>>script.ftp echo bin
rem how do i change the day of mon (04) in filename each day ???
>>script.ftp echo get erevrpt_04.csv
>>script.ftp echo bye
ftp -v -s:script.ftp -i krst.xyz.org
erase script.ftp
@echo on
 

A:Solved: Batch file - place day in file name

Read other 9 answers
RELEVANCY SCORE 54.4

hi folks
i'm using windows xp sp3.
i'm trying to execute a batch file with administrative privilege.

Code:

@echo off
runas /u:administrator "[email protected]" doit.bat

doit.bat

Code:

ipconfig /flushdns
ipconfig /release
ipconfig /renew

thankyou for helping
lexi
 

A:Solved: is this possible using batch file

You might want to check out lsrunas http://www.moernaut.com/default.aspx?item=lsrunas it will allow you to do the same as runas but input a password

So....

Code:
lsrunas /user:username /password:Password /command:"C:\path\to\doit.bat" /domain:computer-name/domain /runpath:C:\

 

Read other 2 answers
RELEVANCY SCORE 54.4

I've created a batch file to do specific tasks.
The file works perfectly and does exactly what I want, but I'd like to have it run at startup on Monday morning.
This is what I've got, but it runs at every boot instead of just Monday.

cls
@ECHO OFF
IF "%DAY%" == "Monday" goto TASK ELSE goto END
:TASK
{various commands}
ECHO Complete
PAUSE
:END

I've also tried numerical values for the day. Where have I gone wrong?

T.
 

A:Solved: Need help with batch file

Read other 13 answers
RELEVANCY SCORE 54.4

I wanted to make a batch file to open several explorer windows and also a notepad and a wordpad file

I've got it working but there is a problem in that it will often open an explorer window and then stop the script until that window is closed. Only then will it move onto the next line in the batch file. Sometimes it doesn't stop and pause and it works perfectly and I have no idea why.

Please help. Thank you.

I'm just doing this:

%SystemRoot%\explorer.exe "C:\DirName\"
%SystemRoot%\explorer.exe "C:\DirName\src\"
%SystemRoot%\explorer.exe "C:\DirName\src\lvideo\"
%SystemRoot%\explorer.exe "C:\DirName\src\filenamer\"
 

A:Solved: Need Help with Batch File Please

Try this: the start command with "" should launch each process without waiting.

The ping command waits for a couple of seconds in between each command.
Code:
@echo off
start "" explorer.exe "C:\DirName\"
ping -n 3 localhost >nul
start "" explorer.exe "C:\DirName\src\"
ping -n 3 localhost >nul
start "" explorer.exe "C:\DirName\src\lvideo\"
ping -n 3 localhost >nul
start "" explorer.exe "C:\DirName\src\filenamer\"

 

Read other 2 answers
RELEVANCY SCORE 54.4

So i was trying to create a compiler out of a BATCH FILE using notepad .
But i keep getting an error saying " blahblah not a valid win32 application"

SO...i thought that all i had to just define the PATH variable in windows....am i wrong? or did I forget something?
 

A:Solved: batch file XP

Read other 7 answers
RELEVANCY SCORE 54.4

Hi. I am trying to write a batchfile that automatically opens some applications for me. I specifically want it to run from an icon on the desktop - rather than on startup. The problem is that it runs the first program on the list and then it doesn't run the next program until I close the first one, anf the same with all the other programs in the file. Can someone help? Here is the contents of the file.

"C:\Program Files\BlitzMax\MaxIDE.exe"
notepad
"C:\Program Files\Internet Explorer\iexplore.exe"
"C:\Program Files\Internet Explorer\iexplore.exe"
"C:\Program Files\Internet Explorer\iexplore.exe"
"C:\Program Files\Internet Explorer\iexplore.exe"

(I want to have multiple windows explorer windows open - I think doing Ctrl-N may be faster but I don't know how to do this automatically)

I'd be very grateful if anyone could help. If so I would also like to have the Master Volume control window open automatically - I normally get it by double clicking on the Volume icon on the Task Bar , which is on the bottom right. I don't know the name for this process/program though.

I know I'm asking a lot but is it possible to have Windows Explorer open the 4 windows (like my batch file *should* do) and go to specified sites - eg one to Ebay, one to my email, etc. It would also be good if it could log in for me automatically - is this possible? - maybe by using just one initial password, the program would then log in... Read more

A:Solved: Need Help with my Batch file

Read other 7 answers
RELEVANCY SCORE 54.4

I am trying to use autorun & have the CD make a dir. on harddrive & load all the file on CD into it. It creates the folder, but doesn't load the files.
md C:\\SNLCJ
copy *.* /s C:\\SNLCJ
what am I doing wrong?
Don
 

A:Solved: Batch file

Read other 10 answers
RELEVANCY SCORE 54.4

I am writing a batch file to remove an older version of software and install a new one. I have the basics done for it. I have the remote computer log into the server and download the install files. I have to copy an "answer.cen" file that needs to be installed to the root drive, so the install doesn't have to ask the user any questions. I know about the %windir% command, to copy the files into the C:\Windows\ folder. Is there some other command that will only copy it to the root directory? I might have a few computers out there that don't have C:\ as the root.

Thanks in advance!

Here is the part I am looking at (in red):

:SS
REM THIS INSTALLS THE NEW SMART SHIELD CLIENT
cls
net use v: /DELETE
echo.
net use v: \\server\shared\RemoteInstall /user:Accounts\**** *******
echo.
echo.
echo Downloading install files DO NOT CLOSE WINDOW!
copy V:\ssedu2.1.0.558.exe C:\
echo.
copy V:\answer.cen C:\
net use v: /DELETE
 

A:Solved: Batch File Help

Found it!
%SystemDrive%
 

Read other 2 answers
RELEVANCY SCORE 54.4

Hi all new to this forum. Anyway i need to run a script when a user logs in and check to see if a certain domain user is part of the local administrators group and if so to add another user to the local administrators group and if not then do nothing.

now i already now on how to add a user to the local administrators group through a batch file, i just need help on how to check if a certain domain user is part of the local admin group and if so add another domain to the local admin group.

Any ideas???
 

A:Solved: Batch File Help

Welcome to TSG!

Something like this should work.

Code:
Net LocalGroup Administrators|Findstr /I /C:"Domain\Username">Nul
If %errorlevel%==0 Net LocalGroup Administrators Domain\Username /Add

If the Domain or username contains spaces it needs to be quoted of course

Or as a one liner (Squashman's idea):

Code:
Net LocalGroup Administrators|Findstr /I /C:"Domain\username">Nul && Net LocalGroup Administrators Domain\Username /Add
 

Read other 2 answers
RELEVANCY SCORE 54.4

Welp

I have a batch file
ftp -s:ads.txt

I have a text file ads.txt
open ftp.blahblah.com
username_here
password_here
cd dfw/regally
lcd c:\myfolder
ascii
hash
prompt
get regally.dat
quit

...
This works fine from a scheduled event. but I need get the 'regally.dat' file off the ftp site using Access 20002. I have used the shell command in macro's and modules and all I get is a empty DOS window, the script doesnt work.

Any suggestions on how this can be done with Access 2002?

Thanks
 

A:Solved: FTP batch file

Resolved: Using the Shell function in Access, you dont need the batch file, you only need the txt or src file.

Originaly I was using Call shell("q:\ads\ads.bat") where this file had the ftp -s:blah.txt
Solution: use Call Shell("ftp.exe -s:blah.txt")
 

Read other 1 answers
RELEVANCY SCORE 54.4

I have created a batch file that when run places a new folder on the desktop. The batch file works great but I want to expand it to create another folder if one already exists, kind of like what happens when one right clicks on the desktop and selects "New>>Folder". If a 'New Folder' already exists then the next new folder is named 'New Folder2'

Here is my basic batch file to create a NewFolder on the desktop:

@echo off
cd "C:\Documents and Settings\Owner\Desktop."
md NewFolder
What can I add to this batch file to create NewFolder2, etc. if NewFolder already exists?

You may ask why do I want to do this when I can just right click on the desktop and select 'New>>Folder', because I just want to be able to do it to learn batch files.
 

A:Solved: Help with batch file

Read other 9 answers
RELEVANCY SCORE 54.4

is there a way to make a batch file that would look at a list and check if a number was in the list. please help me asap

A:[SOLVED] batch file help

Quote:





Originally Posted by winxp rules


is there a way to make a batch file that would look at a list and check if a number was in the list. please help me asap




I propose two solutions.

1. Use the FIND command directly. I've tried it and it can check if a number was in a list (the list in my case was a text file).

Here's an example:


Code:
C:\>find "12" mylist.txt /N

---------- MYLIST.TXT
[9]12

C:\>
This search showed that "12" was in mylist.txt at line number 9. The "/N" parameter causes the line number to be shown.

2. Try this batch file. I made one that appends (every succeeding search result gets saved; the file is not overwritten) the results of each search to a text file. Use it if you want:


Code:
@echo off
find "%1" %2 /N >>searchResults.txt
echo Search completed. Search results saved to searchResults.txt
Save the code as "search.bat" (or another filename).

Use it like this:


Code:
C:\>search 15 mylist.txt
Search completed. Results saved to searchResults.txt
Then look at searchResults.txt to see if it found anything.

Notes:

1. The list you are searching must be in the same folder as the batch file.
2. I only tested this with a text file. I don't know if it will work with a formatted file (i.e. DOC, RTF, etc.).
3. If you want to overwrite searchResults.txt, remove one of the ">" from the batch file (meaning... Read more

Read other 1 answers
RELEVANCY SCORE 54.4

Hello Guys,

I am new creating batch files and im trying to create a batch file that fixes my PC routing table while conecting to VPN, here is the details:
I got stuck while trying to using two diferent variables from diferent files in a command ex.

route add "text from file1" "test from file 2"

here is the code that i am trying to work with:

@echo off

if exist error.txt del error.txt >NUL
ipconfig | FIND "IPv4 Address. . . . . . . . . . . : 14" > ip.txt
for /f "tokens=14 delims= " %%a in (ip.txt)do call ROCESS m=%a

ROCESS
route delete 148.91.0.0 mask 255.255.0.0 %1

--------

What i want is to use the destination ips coming from an outside file to look something like this

route delete %1 %2

Please help
 

A:Solved: Batch file to fix VPN Help

%1 %2 variables come from the command line.

If you write text to a file you can then set it as a variable with the set command.

set /p Var1=<somefile.txt
 

Read other 2 answers
RELEVANCY SCORE 54.4

My Example:

File "9872465.pdf" has been sent to the dropbox folder now the batch file is about to run.I need the batch file to move "9872465.pdf" file to folder "\\xxx\mas200\MAS 200\ASCENT\SITE\2008050069\JOBS\9872486", not sure if it matters but the file will always have the same name as the folder. This batch will need to do this to about 50 different files a day.

I've made a few test files and moving a specific file is quite simple, but I am not sure how to move without using an exact file name and folder location. I'm at a loss on what commands to use. Should I use robocopy? The move command doesn't seem to have enough control on what I want to do. I am not sure if the wildcard will get the job accomplished correctly either.

Need some help.
 

A:Solved: Need batch file help

Read other 16 answers
RELEVANCY SCORE 54.4

HI,

I am new to this site, so i dont know where to post this question. please read completely below about my issue.
if (($database eq "master") or ($database eq "msdb") or ($database eq "model"))

{
print "Excluding system databases from performing Differential or log backups\n\n";

}

my $sqlserverconnectionstring = Win32::SqlServer::sql_init($servername,'mohan','mohan', 'master');
my $sqlstatement = <<SQLEND;
BACKUP database $database TO DISK = N'C:\\backup\\$database.bak'
SQLEND
my $result = $sqlserverconnectionstring->sql($sqlstatement, SCALAR);

when i execute this in command prompt, the output is :

Excluding system databases from performing Differential or log backups

Processed 1688 pages for database 'msdb', file 'MSDBData' on file 11.
Processed 5 pages for database 'msdb', file 'MSDBLog' on file 11.
BACKUP DATABASE successfully processed 1693 pages in 3.895 seconds (3.394 MB/sec).
when i put this in batch file
batch file looks like this:
perl test.pl -d msdb -i localhost >> 1.sysout 2>&1

the output in 1.sysout is:

Processed 1688 pages for database 'msdb', file 'MSDBData' on file 5.
Processed 5 pages for database 'msdb', file 'MSDBLog' on file 5.
BACKUP DATABASE successfully processed 1693 pages in 1.702 seconds (7.768 MB/sec).

Excluding system databases from performing Different... Read more

A:batch job output order is not getting correctly

Please use code tags when posting code for scripts. It is hard to tell where your code starts and stops and where you are just making a general comment. I always put my code and output from my script inside code tags for better readability.

I am going to assume that one of the messages is coming out as standard error and the other message is coming from standard output. I know some programs even like to flip flop them and write everything to standard error for some reason.

I would try reversing your redirection.
Code:
Perl test.pl 2> 1.sysout 1>&2

 

Read other 2 answers
RELEVANCY SCORE 54.4

Hi all,

I am trying to write a batch file in Windows 10 to output day of week (Monday, Tuesday etc) to variable do that I can do certain procedures on differnt days o the week and am having major problems.

If I type DATE /T at command prompt I get 15/01/16 and no day of week.

I have change regional setting so that long date is in correct format but still if I type DATE /T at command prompt I get 15/01/16 and no day of week.

All help appreciated.

Thank you.

A:How to output day of week to variable in batch

DATE /T shows the date, not day of the week. You need WMIC command to get the day of the week:


Code:
wmic path win32_localtime get dayofweek

The output will be a number from 1 to 7, 1 being either Sunday or Monday depending on what is your local setting, if the first day of the week is Sunday or Monday. In my case, European system and Monday as the first day of the week, the command shown in above screenshot (yellow highlight) gave just now the output (green highlight) as 5 (Friday).

Kari

Read other 0 answers
RELEVANCY SCORE 54.4

Hi,
I am making a script that will update my games svn addons automatically and i am trying to make it output to a log file while still showing everything on the console. any help is appreciated.
 

A:batch output logging and display

Read other 12 answers
RELEVANCY SCORE 53.6

Hello, I want to use a batch file to copy a file to my startup folder.

I used

copy myProgram.exe %userprofile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
But I get an error saying that the sytax is incorrect. However I can copy it to other locations.
Any ideas?
 

A:Solved: Copying with batch file

Put double-quotes around the destination, like this :-

copy myProgram.exe "%userprofile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"

The above should all be on one line, with a space between Start and Menu.
You need to do this with any path that contains spaces.
 

Read other 2 answers
RELEVANCY SCORE 53.6

In a batch file or vbs (doesn't matter which and I've tried both) I can't seem to get a window open with size properties, as in width and height in pixels. Also, I need it to not be re-sizable.
All help is appreciated.
Please and thanks!
 

A:Solved: VBS/Batch file help - set size?

You could do it with an AutoHotkey script.

You could use a WinMove command to set the position, width and height of the window. Then use a WinGetPos command in a loop to see if size of the window has changed and if it has put it back to the original size.

You could also check to see if they minimize the window and restore it or make it always on top.
 

Read other 2 answers
RELEVANCY SCORE 53.6

Hey all,

I am trying to make a batch file that will open the wireless application on my computer and run for a certain amount of time.

The information I gathered so far is:
When I go into cmd on windows XP and type the following;
Code:
C:\Program Files\3 Mobile Broardband\3Connect\WilogApp.exe
That opens up the application and automatically connects to the internet.
The next bit I will need it to pause there for around 65 seconds, Then I need it to do the following command;
Code:
TSKILL WilogApp
To close the application.

Do you guys/girls have any ideas on how to go about doing this in a batch file?
 

A:Solved: Making a batch file.

Read other 9 answers
RELEVANCY SCORE 53.6

This batch file will shut down my PC after 30 minutes, shutdown -s -f -t 300. Is there a way to have a desktop shortcut run this file?
 

A:Solved: Icon to run batch file

Read other 8 answers
RELEVANCY SCORE 53.6

Hi,

I am trying to make this batch file for a user to schedule a task whenever they run a batch file. It should schedule it 5 minutes ahead when it runs. So far I got this. Is there a way for me to add 5 minutes to the _time and then pass the variable to the AT command. Thanks!
Code:

SET _time=%time:~0,2%:%time:~3,2%

AT [URL="file://\\10.10.5.4"]\\10.10.5.4[/URL] %_time% /interactive test.bat

 

A:Solved: Batch file schedule

Read other 7 answers
RELEVANCY SCORE 53.6

Code:
start /max itunes.exe
PING 1.1.1.1 -n 1 -w 8000 >NUL
start /max C:\Programs\EvilLyrics\EvilLyrics.exe
taskkill /im GoogleDesktop.exe
taskkill /im GoogleDesktop.exe
taskkill /im GoogleDesktop.exe
taskkill /im GoogleDesktop.exe
PING 1.1.1.1 -n 1 -w 1000 >NUL
"C:\Programs\Google\Google Desktop Search\GoogleDesktop.exe" /sidebar
"C:\Programs\Google\Google Desktop Search\GoogleDesktop.exe" /sidebar
"C:\Programs\Google\Google Desktop Search\GoogleDesktop.exe" /sidebar
start itunes.exe
"D:\Users\Josh\Desktop\Josh's Documents\Computers\Misc\iTunes Quick Launch\Copy of itunes.ahk"
exit

 

A:Solved: Why does this batch file repeat?

Read other 15 answers
RELEVANCY SCORE 53.6

I am trying to write batch file for a very specific purpose. All of it seems to work except for the very last step. In the system registry the key

HKCR\exefile\shell\open\command

the default key should be set to

(Default) Reg_SZ "%1" %*

if it is not it will not properly open exe files. the same goes for the batfile key and the comfile key respectively. Anyway.

if i go to the command prompt (with administrator privileges) and type in

reg add HKEY_CLASSES_ROOT\exefile\shell\open\command /ve /d "\"%1\" %*\"

it will successfully make the change to the registry. However, if I instruct my .bat file to do the same thing. It writes "" " to the value not fixing the problem at all. At first I thought it was a formatting issue, but in theory should it not work the same in a .bat file as it does if I am typing it, since all a .bat file is essentially is a line-by-line instruction of commands.

Please help... Also if I make a .reg file that looks like this

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\exefile\shell\open\command]
"IsolatedCommand"="\"%1\" %*"
@="\"%1\" %*"

it also works but subbing in that value to the batch file does the same thing. again though, typing it will still work.

A:[SOLVED] Formatting for REG ADD in a batch file.

Hi -

Please show me the exact contents of the batch file - place it in code boxes -


Code:
[code]

****place your code here ****
****place your code here ****
****place your code here ****
****place your code here ****
[/code]
The primary problem you are facing is the % sign - in batch files %% must be used, depending on what you are doing. Any FOR loops involved here?

Also - what is the purpose of this?

Regards. . .

jcgriff2

.

Read other 5 answers
RELEVANCY SCORE 53.6

Hi,

I'm relatively new to making batch files. I'm simply using notepad in Windows XP to create and edit one.

What I would like to do is copy a file from my G drive to a location within C:\Program Files

However, when I input the command, source, and destination I get an error saying that the syntax is incorrect. I believe this is due to the phrase "Program Files" being two words where as in the command prompt it likes everything to be one word.

Is there a way to get around this limitation?

Thanks for all your help!

JFresh
 

A:Solved: Batch file question

Example Put it in quotes around the command or use the windows shortnames. You can find the shortnames in windows by typing in dir /x EG. program files in shortname is progra~1

example -

copy "c:\program files\long\mine.exe" "d:\My Documents"
copy c:\progra~1\long\mine.exe d:\mydocu~1

both do the same thing.
 

Read other 2 answers
RELEVANCY SCORE 53.6
A:Solved: Regedit(batch file help)

Read other 10 answers
RELEVANCY SCORE 53.6

I am trying to write a batch file that will open up a specific Excel Workbook. I know how to write a batch file that will open excel, but I want to know how to open a specific workbook, not just excel itself.

Any help is greatly appreciated!!
 

A:Solved: Help writing a batch file

Read other 8 answers
RELEVANCY SCORE 53.6

Hello,

Already have a batch file that saves a list of the files in a certain folder into a text file.

I am using the the /B and /D switches as well as a *.jpg wildcard to create a clean, files only list showing only the jpg files. What I need now is a switch to remove the .jpg extension from the text file (not from files themselves).

example...
abcdef.jpg will be shown in the txt file as abcdef.

TIA
SBF
 

A:Solved: Batch File - Dir switches

Read other 6 answers
RELEVANCY SCORE 53.6

I'm looking for some help with automating a simple batch file that will delete folders created that day. I set it up where i can change the variable (which is the folder name) and delete the folders(24 folder) . But I would like to beable to have the system figure out the date and then assign it to the variable and delete the folders automatically using windows scheduler to kick it off.
Code:

y:
SET date=20090716
cd store01
rd /s /q %date%
cd..
(Which is then repeated for 24 different folders)

Anyone know of a simple way to do something like this? Any help would be apperciated
 

A:Solved: Help automating Batch File

Not sure what the y: you have at the start is, but this should do the trick.
You can specify the complete path to each folder in the For loop, or just the folder name if they are all subfolders of the current folder (C:\Test in this example).
So this will look for folders with todays date in
C:\Test\store01
C:\Test\store 03
C:\Test\store 05 Backup
Code:
y:
CD C:\Test
Call :_GetDate
For %%I In ("store01" "store 03" "Store 05 Backup") Do (
PushD %%I
rd /s /q %_fdate%
PopD
)
Goto :EOF
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Subroutines
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:_GetDate
:: This batch file will always display the same results,
:: independent of "International" settings.
:: This batch file uses REG.EXE from the NT Resource Kit
:: (already installed with WinXP and Vista)
:: to read the "International" settings from the registry.
:: Date is returned as yyyymmdd in variable _fdate
:: Modified by The Outcaste from SortDate Written by Rob van der Woude
:: http://www.robvanderwoude.com
::
Set _Date=%date%
If "%_Date%A" LSS "A" (Set _NumTok=1-3) Else (Set _NumTok=2-4)
:: Default Delimiter of TAB and Space are used
For /F "TOKENS=2*" %%A In ('REG QUERY "HKCU\Control Panel\International" /v iDate') Do Set _iDate=%%B
For /F "TOKENS=2*" %%A In ('REG QUERY "HKCU\Control Panel\International" /v sDate') Do Set _sDate=%%B
IF %_i... Read more

Read other 3 answers
RELEVANCY SCORE 53.6

Is it possible to make a batch file in Windows 7 that would be able to do these 4 actions:

1. Change the Appearence theme, to a specified one.

2. Open up the Screen resolution window and leave it open.

3. Launch an application.

4. When application in step 3 is closed by user, then the resolution window closes, and the Appearence theme is changed back to original one.
 

A:Solved: Batch File action

Read other 16 answers