Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

4551.

Solve : Batch file for network login and file transfer?

Answer»

Hello everyone.

I am a Sr. in mechanical engineering at MSU-Bozeman and am currently in the final semester of my Sr. design project. The last bit of this project is definitly more computer science than traditional engineering, and, needless to say, im waaaay out of my element....but here is what I have got going.

We have a wind turbine installed on campus and we have designed some instrumentation on the wind turbine that records some data. We have used National Instrument's LabView to create a Virtual Instrument (VI) that manipulates this data and makes it look nice and pretty for the end user. There is also a webcam that TAKES snapshots of the turbine. All of this is done on a local computer (call it WAC) that is at the turbine site.

This data and images NEED to be displayed on a WEB page. I am planning on making the VI take a screenshot of itself so instead of data, there will be "data" thats just a picture of the program output. So, there will be a webpage that needs to display 2 images, the webcam picture and the program screenshot.

The webpage is going to be hosted on the College Of Engineering's web server (call it COE). Now, COE and WAC are connected via local network. I can browse (from WAC) to the web directory on COE, but only using my log-in credentials. I do not use my log in credentials to log into WAC....not sure if im being clear here. Basically the web directory cant be accessed on WAC because when this is ATTEMPTED a BOX pops up asking for domain/username and password. Only my login credentials can open the web server.

So now, I need to make a batch file that will log in to the COE domain (so that it can access the web directory) and then transfer the 2 image files from WAC to COE.

Could someone give me a hand or point me in the correct direction?

Your time is appreciated. Thanks in advance. i am not sure about webserver, and how you browse web directory on coe.

but this is how to access another computer local-disk:
first check if the following command works
C:\>net use \\COE /user:domainnamehere/usernamehere
or
C:\>net use \\COE\C$ /user:domainnamehere/usernamehere

if works, it will then prompt password

4552.

Solve : Please let me know?

Answer»

I dont know when the song will be stopped. I dont know the PID.
So what is to do. Is it not possible to CLOSE the media player window?
If possible please GIVE me a code for that,

Thanks
devdutta4 Threads...one Topic.
Do you UNDERSTAND how Forums work ? ?
Is there a reason you need a batch file to SHUT down a Windows process ? ?*sigh*.

4553.

Solve : Please I need the solution?

Answer» PLEASE dont take it badly that the same topic I am ASKING once again
I am a beginer and WANT to learn this field.
Please let me know the batch file code to close media player window.
Excuse me. THANKS
debduttaaCode: [Select]taskkill /IM wmplayer.exeplease STOP asking this question
4554.

Solve : Not working?

Answer»

@echo on
start "" "C:\Program Files\windows media Player\wmplayer.exe" /prefetch:6 /OPEN "C:\abc.mp3"
start "" "c:\abc.mp3"

For /F "tokens=2" %3096 in ('tasklist^|Find "wmplayer.exe"') Do Set Task=%%3096
TaskKill %wmplayer.exe%
Please SEE writing the above batch file I can play the song,but after the
song is finished the media player window is not closing.
Please help so that media player window closes after the is finished.
Please dont be annoyed. THANKS
devduttaa%%3096 ? ? ? ? Really? Why?




joedavis, did you give him that code? How does it KNOW when the song is over?

Is joedavis your real name? You remind me of somebody.
devduttaa, please STOP starting new threads about the same topic.

4555.

Solve : Kill a process?

Answer»
I cant kill a process. Please HELP me,OTHERWISE I cant PROCEED further.

THANKS
devduttaaGoogle for Taskkill.Here ya go: Use REVO Uninstaller to Terminate UNRESPONSIVE Processes
4556.

Solve : Replace str in variable with parameters passed to batch?

Answer»

Hi
I can do this

C:\set a=whatisthis
C:\set b=%a:what=that%

C:\echo %b%
thatisthis

But when i try to do same in batch as
----------outtest.bat----------------
@echo off
setlocal enabledelayedexpansion
SET b=%1
SET S=%2 -- search part
SET R=%3 -- REPLACE part
ECHO b IS %b%
set NEWCMD=%b:%S%=%R%%
ECHO NEW CMD IS %NEWCMD%
---------------------------------------------

C:\outtest.bat whatisthis what that
B IS whatisthis
NEW CMD IS SR%

Since search is variable i am putting % before and after it.. Same is for replace part

Can someone help

Regardscall set NEWCMD=%%b:%S%=%R%%%
or
call set NEWCMD=%%b:%2=%3%%

i think there is other METHOD ALSO.

4557.

Solve : How do I capture the timestamp?

Answer»

Dear all,

I'm WONDERING is there's anyway for me to capture the command ping xxx.xxx.xxx.xxx -t and write the RESULTS to a log file with the timestamp on it?

I'm trying to ping to a offsite server and we encounter occasion line-drop. We need to find out the exact timing as to when and what time did the line dropped.

Thanks to all in advance if you can advise on this.Is this a homework exercise?
Why not just thing simple?
USING ping -t on the internet is a poor practice. The server may kick you off for too much pinging.

Code: [Select]time /T >testing
ping geek9pm.com >testing
type testing
Also the testing file will have time of its creation.

If you need to know when server goes out of SERVE for a commercial reason, like maybe it is your HOST, there are independent firms that will do that for you.

4558.

Solve : Delete File in specific time?

Answer»

How can I DELETE a .txt file created in a BATCH file after 3 seconds or so? Is it possible?Quote from: joedavis on March 30, 2009, 08:21:42 PM

C:\>TYPE del3sec.bat
Code: [Select]@echo off
dir > textfile.txt
type textfile.txt
SLEEP 3
del textfile.txt
type textfile.txt

i didn't know there is sleep command/exe in nt dos.
C:\>sleep
'sleep' is not recognized as an internal or external command,
operable program or batch file.

to delay in nt dos, something that come close to it
C:\>ping -n 3 localhost>nul

for more accurate delay, use vbscript:
wsh.sleep 3000"sleep" is in the windows RESOURCE kit.


http://www.activexperts.com/activmonitor/windowsmanagement/reskit2000/0035/
4559.

Solve : Opening IE tabs with date in url?

Answer»

As implied from a previous conversation, I should start a NEW thread about this topic. Here is an edited copy-paste of the original question:

Hello guys,

(...)


Basically, what I want to do is to open five tabs in Internet Explorer. I have to work with data pages on our COMPANY's intranet. I won't get into details about what they are because that would be very long, tedious and BORING.

The format of the url is: http://XXXX/XXXX/XXXX/cms[date].html

For example, today would be: http://XXXX/XXXX/XXXX/cms30032009.html (so it is DDMMYYYY)

and I need to have the last five days opened in tabs.

- cms[today -4 days].html
- cms[today -3 days].html
- cms[today -2 days].html
- cms[today -1 DAY].html
- cms[today].html

I got my answer for today, but how should I write it for the first four tabs?

Thank you

MartyCode: [Select]with createobject("wscript.shell")
for i=0 to 4
d=right(0&day(date-i),2) & right(0&month(date-i),2) & year(date-i)
wsh.echo d
.run "www.google.com/"&d,1,false
next
end with
got the idea?

4560.

Solve : Date in created file.?

Answer»

Hi There,

Can someone help me with a couple of things I need.
1. I have a .bat file the backs up some DATA using a command line utility. It writes to a file but when I run again I receive an error saying the file already exists.
This is what made me think if I can add todays date to the FILENAME I would overcome that error.

2. When the command line utility is running it produces lines of text showing what it is doing, can these lines of text be written to an output file. I want to do this because I want this batch file to run every night and if anything goes wrong I want to be able to read the output file to see what the error was.

Thanks for your help.

Best Regards,

SteveFor your second problem you can redirect the output of the utility to a txt file like so:
Code: [Select]utility.exe >> output.txt
And for writing the date as the name for the file try this code:
Code: [Select]set day=%DATE:~4,2%
set month=%DATE:~7,2%
set year=%DATE:~-4%
utility.exe >> %day%%month%%year%.txtThis works if your Time format is set to DD/MM/YYYY

But if it's another format then just say so.

Hope this Helps
,Nick(macdad-)you could say /y I think that should just over write the file but it's probably better if you have them dated.IMHO the date used to name a file should be in the format YYYYMMDD so that files listed by the Dir command will be in date sequence.

Quote from: Dusty on March 26, 2009, 03:26:04 PM

IMHO the date used to name a file should be in the format YYYYMMDD so that files listed by the Dir command will be in date sequence.



But they will anyway if you type dir /od, won't they?Hi Guys,

Perfect. Thanks for all your help.

Got it working just how I wanted. Your input was most appreciated.

Best Regards,


Steve.Glad it worked out for you.
Same Hello guys,

I have a very similar question so I thought it won't be necessary to open a new thread, just a follow-up would be enough.

Basically, what I want to do is to open five tabs in Internet Explorer. I have to work with data PAGES on our company's intranet. I won't get into details about what they are because that would be very long, tedious and boring.

The format of the url is: http://XXXX/XXXX/XXXX/cms[date].html

For example, today would be: http://XXXX/XXXX/XXXX/cms30032009.html (so it is DDMMYYYY)

and I need to have the last five days opened in tabs.

- cms[today -4 days].html
- cms[today -3 days].html
- cms[today -2 days].html
- cms[today -1 day].html
- cms[today].html

I got my answer for today, but how should I write it for the first four tabs?

Thank you

Martydont hijack some one elses thread.It is not a hijack. I admit I don't know the habits of this forum but I know that usually, mods frown on starting a new thread about something that already exists (or is very similar to). You don't know the mods here so you can't assume something with out knowing it.No, I don't know the mods here. I was referring to the mods I know on other forums. Geez, I CERTAINLY did not expect that my first post would fire such reactions. Did I touch a sensible issue? If yes, then I APOLOGIZE. Rest assured though, I am not a troll or anything like that. I just asked a simple question..

Edit:
no it just keeps thing simple this way.
4561.

Solve : Cmd or Program to do ls -lrt | tail -1 as done in Unix?

Answer»

Quote from: smartjosh on March 27, 2009, 04:45:04 AM

2. You want to subtract 1 from e.g. 26 to GET 25? Or get the previous day's date?
I want previous day's date.

3. Boundry Conditions >> Meaning Month ends / Year conditions to get previous day's date.

smartjosh, here is the bat way to calculate date difference, source is from wiki, and i haven't tested it throughly, so may STILL contain bugs. if you did have access to vbscript, it's easier to do it with vbscript.
Code: [Select]::source: http://en.wikipedia.org/wiki/Julian_day
@echo off & setlocal
if "%~1"=="" echo USAGE: %0 [interval] & goto:eof

for /f "skip=1 tokens=2-4 delims=(./-)" %%a in ('echo.^|date') do (
for /f "tokens=1-3 delims=./- " %%A in ('echo %date:~-10%') do (
set %%a=%%A& set %%b=%%B& set %%c=%%C
))
echo TODAY :%yy%%mm%%dd%
set/a mm=1%mm%-100,dd=1%dd%-100

::JD
set/a a=(14-mm)/12, y=yy+4800-a, m=mm+12*a-3
set/a jd=dd+ (153*m+2)/5 + 365*y + y/4 - y/100 + y/400 - 32045
::date interval
set/a jd+=%~1

::gd
set/a s1=jd+68569, n=4*s1/146097, s2=s1-(146097*n+3)/4, i=4000*(s2+1)/1461001
set/a s3=s2-1461*i/4+31, q=80*s3/2447, s4=q/11, e=s3-2447*q/80
set/a yy=100*(n-49)+i+s4, mm=q+2-12*s4, dd=e, gd=yy*10000+mm*100+dd
echo %1 :%gd%


test output
Code: [Select]C:\>jd 10
Today :20090330
10 :20090409

C:\>jd -1
Today :20090330
-1 :20090329

C:\>jd -1000
Today :20090330
-1000 :20060704
4562.

Solve : SCREEN CAPTURE?

Answer»

Is there any way with Batch Script or VBS to make a lil app that captures the desktops screen in a predefined time interval like every 3 seconds and then it saves each screen-shot somewhere in a timestamped .jpg file with the users name in the file name like:
2007_12_17___10;45;36__GUMBAZ__.jpg

Is this possible at al..??

This will be for an XP Pro PCI dunno but that'd be cool.Probably not. Not sure how to even attempt this in batch and the VBS manual specifically mentions "You cannot send the PRINT SCREEN key {PRTSC} to an application."

You might try Google. There are probably 3rd party applications that can do this.




That would be a great virus... Yah...This could be used in a malicious manner to steal information or invasion of privacy!

If you are trying to stop someone from doing something or going somewhere, its best to just BLOCK whatever is not acceptible than it is to PLANT this which is possibly illegal if not for recording your own computer useage habits with you as the operator aware of the recorded screen shots.

I use a TOOL called CamStudio for recording Windows GUI processes if that is your intention and you were just looking at a batch or other timed process because you were unaware of 3rd party tools already available.There was a way to capture the screen in VBS...I saw it somewhere on youtube...it worked pretty well.helpmeh, do you have the source code for that?

i have this task that i am doing once daily. capture screenoutput of a PROGRAM, open paint, paste, and resize the image to half, and save as jpg file, and then print.
it would be nice if i can do it in vbs instead of manually clicking here and there.Quote from: Reno on March 09, 2009, 11:51:31 PM

helpmeh, do you have the source code for that?

i have this task that i am doing once daily. capture screenoutput of a program, open paint, paste, and resize the image to half, and save as jpg file, and then print.
it would be nice if i can do it in vbs instead of manually clicking here and there.

I don't have the source...I saw it a while ago on youtube...but it automatically saves the captured image.yesterday i play around vbs, and finally have working code to capture screen.
if anyone still interested on how to do it, let me know, and i will share the code here. I could really use that.Quote from: Helpmeh on March 29, 2009, 05:13:43 PM
I could really use that.

here you go, helpmeh. the solution is not pure vbs.

Code: [Select]'captureie.vbs
d=year(date)*10000+month(date)*100+day(date)
with createobject("wscript.shell")
if not .appactivate("Internet Explorer") then
wsh.echo "Internet Explorer is in tray state or could not be found"
wsh.quit 1
end if

' .sendkeys "%{prtsc}":wsh.sleep 200 'not working

' .run ".\printscreen.exe screen",1,false
.run ".\printscreen.exe",1,false
.run "c:\windows\system32\mspaint.exe",1,false:wsh.sleep 1000

if .appactivate("untitled - Paint") then
'resize to 1x1 pixel & paste from clipboard
.sendkeys "^e1{TAB}1~^v"

'save as ".\ie yymmdd.jpg"
.sendkeys "^sie " & d & "{TAB}{DOWN 2}~~%yy"
else
wsh.echo "Failed to activate Ms Paint"
end if
end with


because there is something wrong with sending printscreen keystroke from vbs, i am using temporary solution by calling win32 api, "keybd_event". so create printscreen.exe with your favourite IDE. here is a sample with VB6.
Code: [Select]Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Const VK_SNAPSHOT As Long = &H2C

Sub Main()
If INSTR(VBA.Command$, "?") <> 0 Then
MsgBox "USAGE: " & App.EXEName & " [SCREEN]" & vbNewLine & vbNewLine & _
"Argument:" & vbNewLine & _
"Screen - capture entire screen " & vbNewLine & _
"If omitted - capture active window"
ElseIf UCase(VBA.Command$) = "SCREEN" Then
'entire screen
keybd_event VK_SNAPSHOT, 0, 0, 0
Else
'active window
keybd_event VK_SNAPSHOT, 1, 0, 0
End If
End Sub

i am still looking for a way to call win32 api EASILY from vbs.
4563.

Solve : can someone edit my autoexec.bat and config.sys please?

Answer»

Ok, so I think I have most of this figured out here all but one line I think? I've loaded the driver for the ethernet card but when I get past the startnet.bat - (I think) and I receive an error that: "Lantastic Redirector (REDIR) must be installed". If I place the redir.exe somewhere in the autoexec.bat I get the error: "Netbios is not present". What should I do with the redirector? Here's the config.sys, autoexec.bat, startnet.bat,

Here is the Config.sys and it all seems to work:

Code: [Select]DEVICE=C:\DOS\HIMEM.SYS
DEVICE=C:\DOS\EMM386.EXE NOEMS novcpi /i=e000-efff
DEVICE=C:\DOS\SETVER.EXE
device=c:\lantasti\protman.dos /I:C:\lantasti
device=c:\lantasti\pcind.dos
DOS=UMB,HIGH
BUFFERS=40
FILES=199
LASTDRIVE=Z
FCBS=4,0
SHELL=C:\COMMAND.COM /P /E:1024
STACKS=9,256
[COMMON]
And here's the Autoexec.bat:

Code: [Select]@ECHO OFF
LH /L:0;1,45488 /S c:\dos\SMARTDRV.EXE /X
LH /L:1,13984 c:\dos\share
PROMPT $P$G
set clipper=f085
PATH \;C:\DOS;
SET COMSPEC=c:\COMMAND.COM
LH /L:0;1,50304 /S COMMAND /E:1024 /C\LANTASTI\STARTNET.BAT
C:\LANTASTI\REDIR.EXE
path=d:\vss;%path%
d:\lantasti\net clock \\master
SET VSSTERM=2
D:

And here is the Startnet.bat:

Code: [Select]@echo off
rem LANtastic Version 6.00 installed 95/12/00 14:45:58
rem (for DOS)

C:
cd C:\LANTASTI

SET LAN_CFG=C:\LANTASTI

rem If LANtastic is DISABLED, SKIP everything.
IF EXIST DISABLED GOTO :STARTNET_DONE

@echo ===== Begin LANtastic configuration =====

PATH C:\LANTASTI;%PATH%
SET LAN_DIR=C:\LANTASTI.NET

LOADHIGH AI-NDIS BIND_TO=PCIND_NIF
AILANBIO @STARTNET.CFG

REDIR MASTER @STARTNET.CFG

IF EXIST NOSHARE GOTO :NOSHARE
SERVER C:\LANTASTI.NET @STARTNET.CFG
NET LOGIN \\MASTER
GOTO :CONTINUE

:NOSHARE
@echo LANtastic server was installed but turned off.

:CONTINUE

rem If CONNECT.BAT exists, run it to set up connections.
IF EXIST CONNECT.BAT GOTO :CONNECT

rem Otherwise set up connections specified during install.
net use d: \\master\c-drive
NET USE LPT1: \\MASTER\@PRINTER
NET LPT TIMEOUT 10
GOTO :CONNECT_DONE

:CONNECT
@echo Setting up LANtastic connections from CONNECT.BAT
rem Build CONNECT.BAT like this: "NET SHOW/BATCH > C:\LANTASTI\CONNECT.BAT"
rem (or run the batch file SETNET.BAT)
call CONNECT.BAT

:CONNECT_DONE
NET POSTBOX

@echo ===== End LANtastic configuration =====

:STARTNET_DONE
cd \
And when I boot up I F8 and do it line by line and I get this below:

Code: [Select]Starting MS-Dos...

MS-DOS will prompt you to confirm each Config.sys command.
DOS=UMB,HIGH [Y,N]?Y
DEVICE=C:\DOS\HIMEM.SYS [Y,N]?Y

HIMEM is testing extended memory...done.
DEVICE=C:\DOS\EMM386.EXE NOEMS NOVCPI /I=E000-EFFF [Y,N]?Y
DEVICE=C:\DOS\SETVER.EXE [Y,N]?Y
DEVICE=C:\LANTASTI\PROTMAN.DOS /I:C:\LANTASTI [Y,N]?Y

MS DOS LAN Manager Protocol Manager v2.0
DEVICE=C:LANTASTI\PCIND.DOS [Y,N]?Y
Loading PCIND.DOS..........
RTL8029 driver (V5.0) is installed

BUFFERS=40 [Y,N]?Y
FLIES=199 [Y,N]?Y
LASTDRIVE=Z [Y,N]?Y
FCBS=4,0 [Y,N]?Y
SHELL=C:\COMMAND.COM /P /E:1024 [Y,N]?Y
STACKS=9,256 [Y,N]?Y

Process AUTOEXEC.BAT [Y,N]?Y
ECHO OFF [Y,N]?Y
LH /L:0;1,45488 /S c:\dos\SMARTDRV.EXE /X [Y,N]?Y
LH /L:1,13984 c:\dos\share [Y,N]?Y
PROMPT $P$G [Y,N]?Y
set clipper=f085 [Y,N]?Y
PATH \;C:\DOS; [Y,N]?Y
SET COMSPEC=c:\COMMAND.COM [Y,N]?Y
LH /L:0;1,50304 /S COMMAND /E:1024 /C\LANTASTI\STARTNET.BAT [Y,N]?Y
C:\LANTASTI\REDIR.EXE [Y,N]?Y
LANtastic (R) Redirector V6.00/AI - (C) Copyright 1994 ARTISOFT Inc.
Serial Number FCA-122234 - 1 node license.

ERROR: NETBIOS is not present
path=d:\vss;\;D:\DOS; [Y,N]?Y
d:\lantasti\net clock \\master [Y,N]?Y

ERROR: LANtastic (R) Redirector (REDIR) must be installed
SET VSSTERM=2 [Y,N]?Y
D: [Y,N]?Y
D:\>

Can any one see what is wrong here? I want this computer (Acually the D: drive) to be shared by two terminals and I want this computer to be NAMED MASTER. I don't understand the "redir" or the netbios part of this. Sorry this is so long but I feel like i'm really close. Thanks a lotAnyone have any INFORMATION on the Netbios setup in ms-dos 6.22? as above?

Also on line 10 of the autoexec.bat I have:

Code: [Select]path=d:\vss;%path%
and when that runs in dos prompt it turns into:

Code: [Select]path=d:\vss;\;D:\DOS;
why does it do that?

4564.

Solve : Batch File Help Needed Please!?

Answer»

Hi,

I current have a server Windows Server 2003 that runs a Trackmania Dedicated Game Server off it.

The trackmania server is working perfectly but I need to get something called Dedimania to start when the computer starts which is a .bat file.

When I log in over RDC and start the bat file manually Dedimania pops up on the Trackmania Server and all it well, but when I log off the bat file ends and Dedimania disappears.

So my question is can I keep the bat file running when I log off or is there someway to make the .bat file run without loading into Windows first?

I have read MANY forum theads etc and tried srvany.exe which puts Dedimania into the services but never actually starts it (never worked out why?)

The other thing I have come across is this HTTP://support.microsoft.com/kb/243486 which seems like it could work but as I have to call the batch file Autoexnt.bat what do I put in there to make the batch file run the dedimania batch file?

Hope that makes sense? srvany.exe does not support batch files - http://support.microsoft.com/kb/137890

Pretty positive there is no way to run a batch file in 2003 without logging into Windows first and/or without being logged into an account. Is there a reason you can't just lock the computer while remaining logged in?



thanks for the reply.

I suppose we could do that but I was trying to find a way that WOULD allow the batch file to run without having the EXTRA work to log in and run the file everytime the machine is reset.If you're concerned about logging into the computer every time setup Windows to auto login. It can be a security risk if other people are around the computer, but you can set it to auto login then set a short time (e.g. 1 MINUTE) for the screen saver to come on with a password.

4565.

Solve : Really I feel helpless?

Answer»

@echo on

start "" "C:\PROGRAM Files\windows media Player\wmplayer.exe" "C:\abc.mp3"
echo Bye
This is not working.

abc.mp3 song is in C:
What is the problem with this batch file; MESAGE is that the file cant be LOCATED.
I am really annoyed . Pleae please
Thanks
devduttaaC:\>ftype mp3file
mp3file="C:\Program Files\Windows Media Player\wmplayer.exe" /prefetch:6 /Open "%L"

TRY this:
if not exist "c:\abc.mp3" echo abc.mp3 not exist
start "" "C:\Program Files\windows media Player\wmplayer.exe" /prefetch:6 /open "C:\abc.mp3"

if still not working try:
start "" "c:\abc.mp3"

4566.

Solve : Help with a boot-discs image?

Answer»

Hi folks, im new here
I just downloaded a 6.22 FLOPPY image and booted it on an virtual PC
Just one thing: How do i install it to the A:\ drive so it permanently boots MsDos on the Virtual Pc and directly write the files to A:\ so i can release the image and put some other things on wihout making MESS?

anyway, cool operating system

Another Question:
Does there exist some kind of program that converts zip's to .img files?could be wrong, but i doubt msdos 6.22 would fit on a a:\drive diskette Quote from: diablo416 on November 27, 2008, 10:03:37 AM

could be wrong, but i doubt msdos 6.22 would fit on a a:\drive diskette

MSDOS 6.22 came on a set of install FLOPPIES but (of course!) it is also possible to MAKE an MS-DOS boot floppy, usually containing config.sys, autoexec.bat, command.com, io.sys, msdos.sys, POSSIBLY mscdex.exe as well.

On40, if you mean, how do I transform a floppy image into a real floppy disk. the answer is with software.

The same software that will make img files from your (extracted) zips.

http://www.google.co.uk/search?num=100&hl=en&safe=off&q=floppy+image+writer&btnG=Search&meta=&aq=5&oq=floppy+imageOh sorry guys. I have been away from a looooonnnggg time. Actually i forgot everything about you.

What i means is: How do you properly install Dos? I really want the whole DOS over on the root drive and away from the floppy.You create a virtual disk and then you create a partition with fdisk, format it and transfer the system files on to it.
4567.

Solve : Ghost Bootable Floppy, need help..?

Answer» HI, I am having trouble on creating a bootable Floppy disk with over 3mb source files. Does anyone knows how to do it? The TECHNICAL Support engineer left earlier this month and he did it SOMEHOW.....

Please help..Floppy maximum size 1.44 MB. Please state what you want to place on floppy.
I remember DMF but, it still will not go to 3 MB.

http://www.alkonost.com/maxformat/You can have 2.88 MB floppies, but you need a special drive. Multiple disks may be the way to go. Or spanned zip files. To the OP: Why didn't you get a new technical support engineer?
Ghost comes with a program to create bootable floppies called "Ghost Boot Wizard.exe". It makes a 2 floppy set with either PC-DOS or MS-DOS. If you have any CD/DVD's that were used by Ghost to backup, the first one will be bootable and run Ghost (assuming that the make disk bootable option was selected at time of creation which everyone I talk to does).
4568.

Solve : I am frustated with batch file?

Answer» PLEASE help me to WRITE a batch file to OPEN a file or FOLDER. I am frustated.

Thanks
devdutta
4569.

Solve : Unable to booy my lapptop?

Answer»

My computer won't start up the power is on and the CURSOR blinks but that's about all it does. How do I BOOT my laptop without a bootdisk I am on win XP CHEERS You can install Image Burn and write a CD from the windows 98 SE boot disk ISO.


http://www.sendspace.com/file/aga2yj

4570.

Solve : Operating System Query?

Answer» HELLO,
I want to install sql server as a database server and Oracle 10 I as a PROGRAMMING language for this i choose windows 2003 server as a operating system..OK.and come to hardware part i have 8 SATA hdd's each one has 300 gb of capacity. my requirement is i want to insert these 8 HDDS into a system by using RAID LEVELS(Leave about configuration). in Raid Levels which level will give 100% data backup(safe).if u give preference for one particular raid level please let me know what are the benefits with that Please suggest me with best answers.

ThanksThis is either your homework or else your employer is the biggest cheapskate I have ever heard of.

I suspect the former.

Quote from: Gracey on March 06, 2009, 05:34:39 AM
Hello,
I want to install sql server as a database server and Oracle 10 I as a programming language for this i choose windows 2003 server as a operating system..OK.and come to hardware part i have 8 SATA hdd's each one has 300 gb of capacity. my requirement is i want to insert these 8 hdds into a system by using RAID LEVELS(Leave about configuration). in Raid Levels which level will give 100% data backup(safe).if u give preference for one particular raid level please let me know what are the benefits with that Please suggest me with best answers.

Thanks

Gracey, when we use raid facility ,we can connect only 4 hard disk,because no any option r available in our motherboard thats why we connect more then 4 HDD. i think like this if any other answer u may get p, please inform me.

The most conservative RAID is where two disk are using together as a PAIR, both have the same data.
But you would read this:
http://techrepublic.com.com/5208-11184-0.html?forumID=56&threadID=187097
Somebody there asked a similar question and got LOTS of answers.
4571.

Solve : How to tag a video clip with a desktop icon with the help of a batch file?

Answer»

Suppose I have a VIDEO CLIP. I like that when I click an desktop icon,the video clip will PLAY first and then the window corresponding to the icon
will open. I want to write a BATCH FILE for this. Please GIVE me a format
of the BATCH file.
THANKS
devduttaaThis is an extension of your previous request.

You do not need to write WORDS like BATCH all in capital letters. It is annoying.

What do you mean by "the window crresponding to the icon"?


4572.

Solve : Division in batch files??

Answer»

Hello everyone.

I'm trying to write a batch file for a school assignment and I'm having a heck of a time figuring out how to divide one number by another. I assume it's possible because add, subtract, and multiply seem to work.

This is the line I'm having trouble with:

set /a SUM1=%num1% / %num2%

I suppose the computer is confused because the / character is already used but I haven't been able to find how it's done. If anyone can help that would be awesome.That should be correct.
Get rid of the space and see if it works for you.Quote from: Carbon Dudeoxide on March 28, 2009, 08:37:33 PM

That should be correct.
Get rid of the space and see if it works for you.

Thanks for the suggestion, removing the SPACES didn't change anything though.

I don't get an error message but it doesn't seem to do anything either. I just get whatever is already in the variable and the division line doesn't seem to AFFECT it.What are %num1% and %num2%

They should be something along the lines of:
set num1=10
set num2=2You can have as many spaces as you like.
Code: [Select]@echo off
set num1=15
set num2=3
set /a sum1=%num1% / %num2%
echo num1=%num1%
echo num2=%num2%
echo sum1=%sum1%
echo %num1%/%num2%=%sum1%

Output:

Code: [Select]num1=15
num2=3
sum1=5
15/3=5I tried your example and it worked perfectly. I played with mine and the results seem inconsistent, I'll get one answer the first time and the correct answer the second time. It seems to have something to do with being in an IF statement, if that makes any sense. This is my file, with a couple extra lines for testing purposes:

Code: [Select]@Echo off

rem ==== Accept user input =======
Set /p num1=Enter num1:
Set /P num2=Enter num2:

rem ===== Calculate and display =====
set /a sum1=%num1%+%num2%
Echo %num1% + %num2% is: %sum1%

set /a sum2=%num1% - %num2%
Echo %num1% - %num2% is: %sum2%

set /a sum3=%num1% * %num2%
Echo %num1% * %num2% is: %sum3%

set /a sum4=%num1% / %num2%
echo %Num1% / %num2% is: %sum4%

rem ==== Check for division by zero =====
if %num2% == 0 (
echo Number not valid, 0 entered
) else (
set /a sum5=%num1% / %num2%
echo %Num1% / %num2% is: %sum5%
)

The last line is the goofy one. The first time I run it, it looks like this:
Code: [Select]Enter num1: 8
Enter num2:2
8 + 2 is: 10
8 - 2 is: 6
8 * 2 is: 16
8 / 2 is: 4
8 / 2 is: 3
The second time I run the same thing and it looks like this:

Code: [Select]Enter num1: 8
Enter num2:2
8 + 2 is: 10
8 - 2 is: 6
8 * 2 is: 16
8 / 2 is: 4
8 / 2 is: 4In a parenthetical statement, such as a FOR loop or an if statement like this, any variables that are set inside the parentheses, in this case, sum5, will expand to a blank or a previous value if there is one.

Code: [Select]if %num2% == 0 (
echo Number not valid, 0 entered
) else (
set /a sum5=%num1% / %num2%
echo %Num1% / %num2% is: %sum5%
)

you have to use delayed expansion. This is because of the way cmd.exe expands the variables at run time.

You have to use this statement (put it at the START just after the @echo off line)

Code: [Select]setlocal enabledelayedexpansion
and in the parentheses use exclamation marks (exclamation points if you are American)

like this

num1 and num2 are OK because they were set before the parentheses but sum5 needs delayed expansion.

Code: [Select]if %num2% == 0 (
echo Number not valid, 0 entered
) else (
set /a sum5=%num1% / %num2%
echo %Num1% / %num2% is: !sum5!
)

Once you are out of the parentheses you can use % signs again for sum5.

Watch out for spaces in IF COMPARISONS. They can catch you out. This is better

Code: [Select]if %num2%==0
This is better still

Code: [Select]if "%num2%"=="0"It works, thank you so much!

I added Code: [Select]setlocal enabledelayedexpansionat the top and used exclamation marks and it works!

4573.

Solve : Simple batch menu question?

Answer»

I'm trying to make a batch menu with option from 1 to 3 but if I was to click say option 7 which is not register, it would automatically take me to option 1. Is there a way that it will only force my batch to accept option from 1 to 3 only. If the user enters say option 7 it would display Main_Menu again.

this is what I have so far but it does not work.

:: ---------------------------------------------------------------
: Main_Menu
:: ---------------------------------------------------------------
CLS
TITLE MAIN MENU
ECHO 1) Sub_MenuA
ECHO 2) Sub_MenuB
ECHO 3) Internet
ECHO.
ECHO.

SET /p Option=Choice:
if "%Option%"=="1" GOTO Sub_MenuA
if "%Option%"=="2" GOTO Sub_MenuB
if "%Option%"=="3" GOTO Internet

thanksQuote from: locbtran on March 22, 2009, 09:00:56 AM

:: ---------------------------------------------------------------
: Main_Menu
:: ---------------------------------------------------------------

I strongly suggest you do NOT use labels to start comment LINES. This is not supported. They can CAUSE problems for example such a line in a loop will break it. Use REM instead.


Code: [Select]
:start
CLS
TITLE MAIN MENU
ECHO 1) Sub_MenuA
ECHO 2) Sub_MenuB
ECHO 3) Internet
ECHO.
ECHO.

SET /p Option=Choice:
if "%Option%"=="1" GOTO Sub_MenuA
if "%Option%"=="2" GOTO Sub_MenuB
if "%Option%"=="3" GOTO Internet

echo.
echo Please CHOOSE 1 to 3 only!
echo.
pause
goto start

Loc B Tran,

Code: [Select]
C:\>type menu.bat
@Echo off

:Start
cls
echo TITLE MAIN MENU
ECHO 1) Sub_MenuA
ECHO 2) Sub_MenuB
ECHO 3) Internet
ECHO 4) Quit
ECHO.
ECHO.

SET /p Option=Choice:
if "%Option%"=="1" GOTO Sub_MenuA
if "%Option%"=="2" GOTO Sub_MenuB
if "%Option%"=="3" GOTO Internet
if "%Option%"=="4" GOTO EOF
Goto Start

:Sub_MenuA
echo Sub_MenuA
pause
Goto Start
:Sub_MenuB
echo Sub_MenuB
pause
Goto Start
:Internet
echo Internet
"c:\program files\internet explorer\iexplore.exe" http://www.google.com/
Pause
Goto Start
:EOF

C:\>

Output of menu.bat

Quote
C:\>type outmenu.txt
TITLE MAIN MENU
1) Sub_MenuA
2) Sub_MenuB
3) Internet


Choice: 1
Sub_MenuA
Press any key to continue . . .

TITLE MAIN MENU
1) Sub_MenuA
2) Sub_MenuB
3) Internet


Choice: 2
Sub_MenuB
Press any key to continue . . .

TITLE MAIN MENU
1) Sub_MenuA
2) Sub_MenuB
3) Internet


Choice: 3
Internet
Press any key to continue . . .

TITLE MAIN MENU
1) Sub_MenuA
2) Sub_MenuB
3) Internet


Choice: 7

TITLE MAIN MENU
1) Sub_MenuA
2) Sub_MenuB
3) Internet
C:\>
thank you

the code works perfectly.
4574.

Solve : Compare file date to system date and copy to archive?

Answer»

Hi team,

I've created a batch file which sets off a series of processes.
I want to add a line into the batch file to test if the date of the file is today. If not then stop processing.

At the end of the batch, I want to copy SPECIFIED FILES to archive.

How would I go about these two requirements?

Cheers
Bernard
How is the file named? like: 03-26-2009.txt
Quote from: macdad- on March 26, 2009, 06:21:20 AM

How is the file named? like: 03-26-2009.txt


I believe it's a file creation date that he wants to check, not a file name, but of which file it isn't clear.for today date, there is no need to ask for user system date format, check the FOLLOWING and you will understand.

Code: [Select]+C:\>echo %date%
Thu 03/26/2009

+C:\>echo %date:~-10%
03/26/2009

+C:\>set d=>file.txt & for %a in (file.txt) do @set d=%~ta & echo %~ta & call echo %d:~0,10%
03/26/2009 08:50 PM
03/26/2009

the %~ta in for loop output MODIFIED date i believe. so for creation date, using dir command is one of the method.Quote from: Reno on March 26, 2009, 07:53:40 AM
the %~ta in for loop output modified date i believe. so for creation date, using dir command is one of the method.

It returns file creation date on my system

Also, date string will be different in non-US locales.
now i set my regional setting to albanian:

Code: [Select]+C:\>echo %date%
2009-03-26

+C:\>echo %date:~-10%
2009-03-26

+C:\>set d=>file.txt & for %a in (file.txt) do @set d=%~ta & echo %~ta & call echo %d:~0,10%
2009-03-26 09:08MD
2009-03-26

we only need to check for equality of 10char string here. no math involved, and no yy mm dd parsing.
only works for today date though, except bulgarian.Quote from: Reno on March 26, 2009, 08:14:42 AM
we only need to check for equality of 10char string here

You're right.
Quote from: Dias de verano on March 26, 2009, 07:35:33 AM
I believe it's a file creation date that he wants to check, not a file name, but of which file it isn't clear.

FINFO >I want to add a line into the batch file to test if the date of the file is today. If not then stop processing.

I can see the confusion I've created here. Sorry about that. I want to test to see the file creation date for NEWBLUES.dbf is the same as the system date; if it is then continue processing. If it is not then the NEWBLUES.DBF is from an earlier date and we don't want to process this.

Does this make more sense?

>At the end of the batch, I want to copy specified files to archive.

I meant here, to copy the files into a compressed file.

Cheers
Bernard
4575.

Solve : Drag and drop directory on batch file to process files and in subdirectorys?

Answer»

I am trying to write a batch FILE to change ID3 info in MP3 files. I would like to DRAG and drop directory on batch file to process files and in sub-directorys. How would I code the drag and drop part?Code: [Select]@echo off

:loop
for /f "tokens=*" %%a in ('dir/b/s "%~1\*.mp3"') do (
echo %%a
)
if not %2.==. shift &AMP; GOTO:loop
pause

support multiple directory drag&dropPerfect! THANK you!

4576.

Solve : Called batch file hangs - no return value?

Answer»

Hello

I have a batch file that calls another. In the called batch file I am stopping a windows service, restarting a device (using devcon) and restarting the service. I use this arrangement on a media pc to restart a tuner card on resume from standby. Most of the time this works fine. From time to time however the devcon statement in the called batch file hangs. As a consequence the calling batch file GETS no response, never exits and the PC sits there with a blank screen. As far as I can ascertain I am not getting a return value from the called batch file. As all of this happens in unattended mode I am looking at timing OPTIONS in the calling batch file such that if a response is not received within a nominated period of time I restart the PC. Are there any techniques that forum members could suggest to deal with this? Have you tried a time delay at the end of the first and second batch to make sure that the process is complete before the batches end. Had a problem once were a batch starting a POS Service for cash registers would hang randomly, but when adding a time delay before exit of the batch it fixed it... There are a number of ways to add a time delay. using Choice, Ping, Sleep, and other methods to use up cpu cycles and burn some time before exiting.Thanks I shall try them.

Pseudocode will be something LIKE

Call b.bat
Wait some time
Evaluate errorlevel
If not==0 then reboot

My concern will be to make sure that I am catching a return code from the originally called batch file (b.bat) and not from whatever process I use to wait.

Will advise how I go.

Cheers
Quote from: cjsmelb on March 18, 2009, 01:20:05 AM

Wait some time

quick question- what are you waiting for?

The line after the CALL command will only be executed after everything in the CALL'd batch is finished executing.if b.bat never return/hang, how would you ever get an %errorlevel% on a.bat??? even the next line after call b.bat is not going to be processed.

my temporary suggestion is: (if i interprete your problem correctly)
1. create a timer.bat to check if devcon is still running. (run timer.bat as another process/thread)

as your description is pretty vague, not to mention my english and interpretion skill is very bad as well, and i don't do mind-reading either.
why not you post your code so we can help you better.Thanks for the responses. I've attached my code below. Hope it makes some sense.

************

Below is the calling batch file. Fairly simple and PIPES the output to a log file. It is in this batch file that I would like to TRAP the response code from the called batch file. The parameter is assigned by Windows' Task Scheduler which triggers this process in the first place - typically it is a simple text statement such as 'ScheduledTask' helpful as an audit trail.

Primary: MyStart.bat

call c:\MyFiles\mystartexec.bat %1 >> c:\MyFiles\mystartlog.txt
exit

***********************************************

Below is the called batch file. The issue I have is that from time to time the devcon statement (and once or twice the net start statement) fails to execute and the process essentially hangs. Why devcon hangs is a question I have been unable to answer but will continue to investigate (the device itself is a Hauppauge TV tuner card). In the short term though I'd like to identify that the problem has occurred and handle it externally and the only reliable way given the situation is to reboot. The internal logic (in mystartexec.bat) of trapping the devcon return code is not working (presumably because it has hung) so my thougth was to identify the problem in mystart.bat by allowing some reasonable period of time for a response from mystartexec.bat and then if nothing had been received assume a problem and reboot. The various echo statements are there simply to log progess so that I can debug.

Called: MyStartExec.bat

@echo off
echo *****************************************
time /t
date /t
Echo Resuming
Echo Source - %1
NET START | FIND "Windows Media Center Receiver Service" > nul
echo Net find error level is %ERRORLEVEL%
if %ERRORLEVEL% == 2 goto Trouble
if %ERRORLEVEL% == 1 goto Stopped
if %ERRORLEVEL% == 0 goto Going

:Trouble
Echo Other error so best to restart
echo Trouble error level is %ERRORLEVEL%
shutdown -r -t 01
goto end

:Stopped
Echo Media Centre was already stopped or maybe not exist but try devcon
goto Devcon

:Going
Echo Media Centre can now be stopped
net stop "Windows Media Center Receiver Service" /y
echo Stop media service error level is %ERRORLEVEL%
if %ERRORLEVEL% == 1 goto Trouble
if %ERRORLEVEL% == 0 goto Devcon

:Devcon
echo At Devcon
devcon restart usb\vid_2040*
echo devcon error level is %ERRORLEVEL%
if %ERRORLEVEL% == 1 goto Trouble
if %ERRORLEVEL% == 0 goto Continue

:Continue
rem ping 1.1.1.1 -n 3 -w 1000 >NUL
echo At Continue
net start "Windows Media Center Receiver Service"
echo net start error level is %ERRORLEVEL%
if %ERRORLEVEL% == 1 goto Trouble
%systemroot%\ehome\ehshell.exe /homepage: RecordedTV.BrowsePage.xml /PushStartPage: True - Recorded TV
echo WMC error level is %ERRORLEVEL%
goto end

:end
time /t
echo end
echo ****************************************
exitadd the following batch file:
Code: [Select]::ProcessTimer.bat
@echo off
if "%~1"=="" echo Usage: %0 ProcessName & goto:eof
%2start %comspec% /c %0 %1 :: & goto:eof

>nul ping -n 60 localhost
tasklist|find "%~1" && (taskkill/f /im "%~1" || %0 %1)
::pause

then change this line:
devcon restart usb\vid_2040*
to
call processtimer "devcon.exe"
devcon restart usb\vid_2040*


the same goes for net start:
call processtimer "net.exe"
net start "Windows Media Center Receiver Service"



what the ProcessTimer doing is wait 60seconds, then check if the process still running, if yes, force kill it, if it's still running, try again.

Warning: Killing a running process might produce unexpected result.


this is from the helpfile tasklist/? and might be interest for you:
Filters:
Filter Name Valid Operators Valid Value(s)
----------- --------------- --------------
STATUS eq, ne RUNNING | NOT RESPONDINGThanks for the suggestion. Have been unavailable a few days will try tonight and advise.
Cheers
4577.

Solve : Related to internal speakers (please do read..!!)?

Answer»

I have a software that results in a series of beeps from the internal speakers of my CPU.
What i need to do, is to count the number of these beeps emitted...as those are ABSOLUTELY essential for a program that i'm writing.
All online forums i've seen have given INFO on how to enable/disable the internal speakers....but nothing else.

Is it possible to , say, send these beeps (output of internal speakers) as input to any other program( something like matlab)....with the help of which i can count the number of beeps??? Or is there anything else i can do?

Ideas or implementation details would really be appreciated! Thanks! You could plug a microphone into the SOUND card, place it near the speaker and use some kind of recording software and later display the result e.g. in Wavedit as a waveform display and count the beeps manually or there MAY be some kind of analysis software that would do this. Well....i din WANT to count it manually....if there's any means of sending this sound(internally)...say thru some particular pins or some port or something...to some kinda software like MATLAB...or any software that would take this input and count the number of beeps...it'd b really helpful

Any thoughts or any softwares known that could do this?I think that you may as well accept that it is impossible.
well i would'nt say impossible! there's always a way to do things!
If we do come up with something, il definetely post an answer to this thread
But thank you anyway for your time.
Any other suggestions from anyone would be welcome.I found a way to count the number of beeps

Its simple programming using C....i found out the port which emits the beeps and from there wrote a program to count the beeps emitted from that port...

I wrote a program specific to my application though...but if anyone's interested to know how...then do post a query here...i'll change the code and put it up!

yaaaaaaaaaaaaaaaaaaaaay
It is possible, after all

4578.

Solve : General format of a to run a program in window mode.?

Answer»

I was trying to run a video file with PLAYER. But I don't find the to run a program (specialy .EXE file).
HELP ME PLEASE.What exactly are you trying to do?
Also, are you trying to do this with Command Prompt?

To start an application/executable with CMD, the command is: start "' "C:\path\to\file.exe"Thanks for response.
What I want to make a which would:
1) play a video file with ,SAY, media player or any other player for a period then
2) go to any other programm,say, to OPEN and so on.
All in window mode,[ not in Command Prompt].
-------------------------------
With regards, spdCHF.Next time, don't start a new topic to reply. Just hit

Anyways, I don't think what you want to do is possible.

You can start Windows Media Player and MS Word simultaneously, but not for example after the song finishes, open Word. It doesn't work like that.

Why do people think Command Prompt can do all these magical things?Never said an EXE couldn't run from Command Prompt......Quote from: Carbon Dudeoxide on March 28, 2009, 09:23:27 AM

Why do people think Command Prompt can do all these magical things?

It must seem very advanced to them. Like what uber-geeks do with their Unix boxes. As Arthur C. Clarke said, "Any sufficiently advanced technology is indistinguishable from magic". (His "third law of prediction".)

Disregarding the "not in command prompt but windows mode"

1. If you want to play a vide with VLC player or something you would set VLC as the default
program to start that kind of video file. With that being said, to start the video you would do:

Code: [Select]start (path to video file)

2. Then if you want to play it for a certain amount of time you would do and start another program you would
do:

Code: [Select]start (path to file)
ping 127.0.0.1 -n (amount of time to wait)
taskkill (video).*
start (path to microsoft word)

This is all disregarding the windows mode THING. But you could put this in a batch file (a text file with a .bat extension)

In response to Joedavis' post, you can just put the following:

Code: [Select]start wmplayer
start winword
It is not what he wanted though.
4579.

Solve : Menu Batch not working?

Answer»

I am trying to get this menu batch to work but every time I run it it just scrolls threw start to command prompt.
I Am running windows xp

Code: [Select]@Echo off
:start
cls
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
echo º Main Menu º
echo ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
echo º 1.Clear Backup disk º
echo º 2.Backup Files º
echo º 3.Restore Data º
echo º 4. Quit º
echo º º
echo º º
echo º º
echo ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
echo.
echo ===============================
choice /c [:]1.2.3.4. Enter option
echo ===============================
Echo.
If Errorlevel 4 Goto Exit
If Errorlevel 3 goto 3.bat
If Errorlevel 2 goto 2.bat
If Errorlevel 1 goto 1.bat


:1.bat
RD /s /q c:files
cls
RD /s /q a:files
Echo The backup has Been Deleted
Echo.
pause
goto Start

:2.bat
md files
Xcopy e:Files a:files /e/k
pause
Echo Your files have Been Backup
Echo.
tree /f a:
pause
Goto Start

:3.bat
md c\ files
Xcopy a:\files C:\files /e /k
pause
echo The files Have been Restored
echo.
Tree c:files /f
pause
Dir c:\files /s
pause
goto Start

:exit
c:
pause
c:






Any Help would be grateThe first thing I would CHECK is does Choice.exe EXIST on your pc, it is not part of the XP install, so you need to get it.

Change the first line of the batch to @Echo On, so you can see the results of each command, that might give you another clue as to why it isnt working

GrahamI don't have choice on my comp where can i get it if not is there a other way to get the menu to work.Quote from: mdf1 on March 25, 2009, 01:55:08 PM

I don't have choice on my comp where can i get it if not is there a other way to get the menu to work.

You can use SET /P with IF and that will work just as well.

Code: [Select]:loop
set /p choice=
if %choice% == 1 goto 1
if %choice% == 2 goto 2
if %choice% == 3 goto 3
if %choice% == 4 goto 4
Echo You must enter EITHER 1, 2, 3 or 4!
goto loop
Modify that to your uses, but it should fit fine.Code: [Select]@Echo off
:start
cls
echo
echo Main Menu
echo
echo 1.Clear Backup disk
echo 2.Backup Files
echo 3.Restore Data
echo 4. Quit
echo
echo
echo
echo.
echo.
echo ===============================
choice /c [:]1.2.3.4. Enter option
echo ===============================
Echo.
If %Errorlevel%==4 Goto Exit
If %Errorlevel%==3 goto 3.bat
If %Errorlevel%==2 goto 2.bat
If %Errorlevel%==1 goto 1.bat
Batch can't use letters / symbols not on your keyboard.Could you please clarify?
4580.

Solve : Batch - UPS Load Test Logger?

Answer»

I have a stack of UPSS that the company wants to test the health of and instead of having to baby SIT them and pay attention to when they drop out to calculate amp hour draw to figure out the battery health under a 100 watt light bulb draw, I came up with this batch file to record the pings to a low draw network device that is also powered through the UPS.

This batch is started when the power strip is shut off and the UPS is using its battery to maintain the 100 watt dummy load light bulb.

The batch currently just keeps logging until it is stopped manually, however I was wondering if there was a way for this batch to be given the smarts of testing the logged echo from the ping to test for "Request timed out." or even"Request" which is not part of a successful ping to WRITE then the date/time and exit the batch.

Currently I have a batch that works, but its dumb, and makes for larger than needed log Text file to search for the start and stop time.

Also if anyone has any better ways to go about this test with a batch or a vb script I am open to alternative solutions.

This is also a tool that would be used on and on from now on to continue to test UPSs that come and go from our IT Service Department. So that is why I am looking for a better way of going about this testing and logging it.

* Was thinking that since you cant read the echo directly from PING, that maybe the batch can be a 2 part functionality where the first part writes 10 pings, and the second part reads in the UPSTest.txt file and searches for "Request timed out." and IF not found then loop back to step 1 to record another 10 pings, then test again in step 2. If step 2 tests and finds "Request timed out." then write the date and time with %date% and %time% to the UPSTest.txt file and exit the batch.


Code: [Select]@echo. UPS Test Started on %date% at %time%>>UPSTest.txt
:loop
@echo...........>>UPSTest.txt
@echo...........>>UPSTest.txt
@echo. 10 Ping Interval Marker %date% at %time%>>UPSTest.txt
@echo...........>>UPSTest.txt
@echo...........>>UPSTest.txt
ping 192.168.2.231 -n 10 >>UPSTest.txt
goto loop1. What are all those @echo............ lines for? I don't see what purpose they serve, apart from bulking up the log file.

2. You can use the && operator to see if the ping WORKED or not

Code: [Select]ping 192.168.2.231 -n 10 >>UPSTest.txt && goto loop
echo Ping failed on %date% at %time% >>UPSTest.txt
3. Why don't you just do @echo off at the beginning then youn wouldn't have to start every echo line with a @?
Thanks Dias!

My batch tends to be sloppy at times from debugging without clean up or forgetting to use easier methods...Thanks for pointing out this better clean coded solution

4581.

Solve : Could someone make it for me...?

Answer»

Hello,

here is a request for a passionated guy...

I started an intenship in a company in which I can't install new softwares. However, I'd like to log automatically my arrival and departure times every days.

I know it's POSSIBLE and for sure it is easy for the experimented... but I don't want to spent time on it (I already have to deal with so many other languages).

Could someone code me
- a batch script that logs the time when I log in windows xp (I will put it in startup folder).
- and a batch script that I will use to shutdown the computer right after logging the current time.

I don't want to use an executable as I want to be sure it's not a virus or something... I don't want to be fired.

Thanks in advance to whom interested
login.bat
Code: [Select]>>c:\log.txt echo [%date% - %time%] %username% logged in

logshut.bat
Code: [Select]>>c:\log.txt echo [%date% - %time%] %username% logged off
shutdown -s

untested.Works perfectly. Thank you very much.

Unfortunately shutdown isn't allowed for me...
"A required privilege is not held by the client"

Nevermind... I'll shut down the computer by myself after logging...
sometimes being lazy is seems more exhausting Quote

I started an intenship in a company in which I can't install new softwares.

Beware - your internship may be brought to a sudden halt if what you are doing is not permitted by company rules.

Quote
However, I'd like to log automatically my arrival and departure times every days.

This may already be being MONITORED without your knowledge.

Quote
"A required privilege is not held by the client"

Your unauthorized ATTEMPTS to extend your existing privileges may ALSO be monitored.

Don't be so paranoid... nobody will fire an employee because... he wanted to log automatically his working hours!!

Quote
This may already be being monitored without your knowledge.
Yeah actually it is done for all the employees via smart cards except for interns who are monitored "visually" by the supervisors. So I wanted to know precisely my working time... as I always do extra time.

Quote
Your unauthorized attempts to extend your existing privileges may also be monitored.
Definitely... and maybe EVEN this message I'm writting to you may be moniited... so what... it's not like I had something to hide.

About the failling "shutdown" command... does somebody know a solution to automatically launch this script when I'm shutting down the computer manually (via start->shutdown button)?1. rundll32 shell32,#60
this popup the standyby/shutdown/restart dialog in my xp

2. copy c:\windows\system32\shutdown.exe and rename it as a new name. eg. sd.exe
then at bat file:
sd -s

3. type the following on command prompt, and see which one is accessible (in case the above two option doesn't work:
gpedit.msc
regedit
wmic
cscript


Quote from: Derdonn on March 27, 2009, 06:29:15 AM
About the failling "shutdown" command... does somebody know a solution to automatically launch this script when I'm shutting down the computer manually (via start->shutdown button)?
if your windows is xp pro, do you have access to gpedit.msc?Just fyi, Shutdown -s -f will force shutdown.
4582.

Solve : batch file to open a word file and goto a special bookmark?

Answer»

How can I write a batch file to open a word file and goto a special bookmark? no you can't , not in batch.
Use vbscript with COM to do that.:)thanks a lot!shelam,

create a macro in the word document, name it GotoBookmark, paste the following code:
Code: [Select]Sub GotoBookmark()
Application.ActiveDocument.Bookmarks("bookmark_name").Select
End Sub
notes: replace the "bookmark_name" with appropiate name of your bookmark.

on the batch file, paste the following code:
Code: [Select]"c:\program files\microsoft office\office12\winword.exe" "c:\document and settings\administrator\my documents\test.doc" /mGotoBookmark
notes: point winword.exe to the correct path on your system, and also the .doc file

yes i know, not entirely pure batch solution. kind of cheating by combining it with macro but, you could do the whole thing with a single VBS script, couldn't you, using Word.Application and directly accessing the bookmarks collection?

this worked for me:

syntax is "gotomark.vbs "

the indenting kind of sucks. I blame notepad.

Code: [Select]if wsh.arguments.count < 2 then
WScript.echo "Not enough arguments. Required syntax:"

wscript.echo CHR(13) + CHR(10)
wscript.echo "wordmark <filename> <bookmark>"

Else






on error resume next
'Set wordapp = GetObject("Word.Application")
set wordapp = createObject("Word.Application")
if err <> 0 then
'wscript.echo "failed to acquire Word COM server object"

Else
on error resume next
set newdoc = wordapp.Documents.Open(wsh.arguments(0))
if err <> 0 then
wscript.echo "Failed to open word document, " + wsh.arguments(0)
wordapp.quit
else
wordapp.Visible=true
newdoc.Bookmarks.Item(wsh.arguments(1)).select
end if

end if
'wordapp.quit
end if
Quote from: BC_Programmer on March 23, 2009, 08:03:47 AM

but, you could do the whole thing with a single VBS script, couldn't you, using Word.Application and directly accessing the bookmarks collection?
Quote from: shelam on March 22, 2009, 10:17:01 PM
How can I write a batch file to open a word file and goto a special bookmark?

hmmm, because he is looking for a batch solution??

batch+macro <-- and this one has the batch part Quote from: Reno on March 23, 2009, 08:34:36 AM
hmmm, because he is looking for a batch solution??
depends write a vbscript, execute from the cmd.exe as
Code: [Select]cscript <my_vbscript.vbs>
and save it as a .bat file. would you call that batch? Quote from: ghostdog74 on March 23, 2009, 08:37:34 AM
depends write a vbscript, execute from the cmd.exe as
Code: [Select]cscript <my_vbscript.vbs>
and save it as a .bat file. would you call that batch?

wsh+batch??I don't see any reason to even involve batch here except as a stub to execute the script.

Now if I wrote the script in perl I could see it- since not EVERYBODY has a Perl interpreter; but VBScript is included in all versions of WINDOWS from W2k up (I believe it's in win98, but I'm not sure)

we are exploring script because:

Quote
How can I write a batch file to open a word file and goto a special bookmark?
is impossible without modifying the Document (which kind of limits the documents one can use it on to ones that contain this macro), thus my solution which works with almost any Doc file containing bookmarks. you took the "liberty" of using a macro within the document- I basically conglomerated all the logic from both the macro and the batch into a single abstract solution.

Basically use the best tool for the job- it's kind of silly to go dancing around in a Word document to add macros for use with a batch when a script can perform the same thing in a FAR more abstracted manner to any word document that contains bookmarks.


Anyway- does GetObject exist in VBScript? my original idea was to try to open the document specified in an existing word window- But GetObject doesn't Seem to work. I haven't used it in a while, and cannot remember if getobject err's out if the CLASSNAME isn't in the ROT or wether it will implicitly create the object and return it...
Set wordapp = GetObject(,"Word.Application")

adding getobject to BC_Programmer code:
Code: [Select]if wsh.arguments.count < 2 then
WScript.echo "Not enough arguments. Required syntax:"
wscript.echo CHR(13) + CHR(10)
wscript.echo "wordmark <filename> <bookmark>"
Else
on error resume next
Set wordapp = GetObject(,"Word.Application")
if err <> 0 then
err.clear
on error resume next
set wordapp = createObject("Word.Application")
end if
if err <> 0 then
wscript.echo "failed to acquire Word COM server object"
Else
on error resume next
set newdoc = wordapp.Documents.Open(wsh.arguments(0))
if err <> 0 then
wscript.echo "Failed to open word document, " + wsh.arguments(0)
wordapp.quit
else
wordapp.Visible=true
newdoc.Bookmarks.Item(wsh.arguments(1)).select
end if

end if
'wordapp.quit
set wordapp=nothing
end if

with proper indention fix Quote from: Reno on March 23, 2009, 09:03:56 AM
Set wordapp = GetObject(,"Word.Application")

thanks reno, I suspected it was some convoluted parameter list.

and with that the line:

Code: [Select]set wordapp = createObject("Word.Application")
can become
Code: [Select]Set wordapp = GetObject(,"Word.Application")



Quote from: BC_Programmer on March 23, 2009, 09:09:10 AM
thanks reno, I suspected it was some convoluted parameter list.

and with that the line:

Code: [Select]set wordapp = createObject("Word.Application")
can become
Code: [Select]Set wordapp = GetObject(,"Word.Application")

THANK you too for the vbs code.

i dont think createobject line should be replaced by getobject.Quote from: Reno on March 23, 2009, 10:00:15 AM
thank you too for the vbs code.

i dont think createobject line should be replaced by getobject.

well... not the way it is now.

Code: [Select]GetObject("",classname)

will do the implicit creation if the program isn't running, whereas not supplying the first argument will cause it to err if the program isn't running.


Also if CreateObject succeeds but we fail to open the file, we should also call Quit(). But if Getobject succeeds and we can't open it we should leave it open since the user had word open. Right now I have it quit if it cannot open the file, regardless.Quote from: BC_Programmer on March 23, 2009, 10:05:43 AM
well... not the way it is now.

Code: [Select]GetObject("",classname)

will do the implicit creation if the program isn't running, whereas not supplying the first argument will cause it to err if the program isn't running.


Also if CreateObject succeeds but we fail to open the file, we should also call Quit(). But if Getobject succeeds and we can't open it we should leave it open since the user had word open. Right now I have it quit if it cannot open the file, regardless.
i don't see any difference between GetObject("",classname) and CreateObject(classname). i can't get a working code with just GetObject(), it still created 2 instance of WinWord.exe. i am curious if this can be done, whether getobject & createobject can be shortened to GetObject("",classname). if it works, this can save few lines of code. it might be specific to VB6, since that's how I tested it.

Word wasn't running, and "GetObject(,"Word.Application") just errored with "ActiveX Component Cannot create Object"

but using GetObject("","Word.Application").Visible=True started word- even though it wasn't running.

Looked in the docs- this explains it:

Quote
If PathName is a zero-length string (""), GetObject returns a new object instance of the specified class type. If the PathName argument is omitted, GetObject returns a currently active object of the class type specified in Class. If no object of the specified type exists, an error occurs.

I've always thought they had kind of silly semantics if you ask me. but it's better then trying to enumerate the ROT ourselves...
4583.

Solve : ...batch file to execute a command after a program closes?

Answer»

...can SOMEONE help in the codes needed in order to EXECUTE this

...i will run the PROGRAM USING a batch file
...when i close the program it will PROCESS the next batch file
Quote from: fuehrer on March 27, 2009, 05:28:56 PM

...can someone help in the codes needed in order to execute this

...i will run the program using a batch file
...when i close the program it will process the next batch file


In the batch file

Code: [Select]start /WAIT "" "Program.exe"
nextbatch.bat
4584.

Solve : filter a text file using batch?

Answer»

Is it possible to use a DOS to EXTRACT FILE names from an text file and copy those files to another DIRECTORY?
example input from text file
03/22/2009 11:10 PM 40,700 btch001338.PRN
03/22/2009 10:27 PM 40,715 btch000425.prn
03/22/2009 10:27 PM 40,727 btch000431.prn
03/22/2009 10:27 PM 40,730 btch000436.prn
03/22/2009 10:27 PM 40,833 btch000435.prn
03/22/2009 10:27 PM 40,922 btch000433.prn
I would like to copy the btch...prn files to another directory from this list.Code: [Select]@ECHO off
REM cut here ------------------------------------------------------------
REM Create test file
REM
echo 03/22/2009 11:10 PM 40,700 btch001338.prn > textfile.txt
echo 03/22/2009 10:27 PM 40,715 btch000425.prn >> textfile.txt
echo 03/22/2009 10:27 PM 40,727 btch000431.prn >> textfile.txt
echo 03/22/2009 10:27 PM 40,730 btch000436.prn >> textfile.txt
echo 03/22/2009 10:27 PM 40,833 btch000435.prn >> textfile.txt
echo 03/22/2009 10:27 PM 40,922 btch000433.prn >> textfile.txt
REM cut here ------------------------------------------------------------


REM edit list file and destination folder names

REM file containing list
set readfile=textfile.txt

REM folder to move files to
set destfolder=C:\Path To\Folder

REM delete the word echo after you have run the file
REM and you are satisfied

for /f "tokens=1-5 delims= " %%A in ( ' type "%readfile%" ' ) do (
echo move "%%E" "%destfolder%"
)


Worked like a charm. Thanks

4585.

Solve : RD batch file?

Answer»

I am using the following line in a batch FILE, but it always ask if its a file or a directory. How do I get around this? I need it to run unattended nightly.

RMDIR /S /Q "J:\backup"That command should would fine with no errors, TESTED in Vista and XP with no issues. What may be happening is that there is a file and directory with the same name and maybe that's CONFUSING it. Maybe try adding a backslash to the end, e.g.

rmdir /s /q j:\backup\That did it. THANKS for the help.Glad to HEAR and you're welcome.

4586.

Solve : sechduled bat file setup for scans?

Answer»

I want to make a bat that I just run from my desktop that does it at certain TIMES then after start one then the others follow like open and exit flow. But how do I really go about that? for like the time I want the clock to be the trigger. Thought that it be easier since i wouldnt have to set setting across multi machines, just MOVE the file and if its all there just run it like as is.Use WINDOWS Scheduled Task Manager

Start --> all programs --> accessories --> System Tools --> Scheduled Tasksthen I would have to do that for each acrossed my network.try CODE: [Select]at /? in cmd

but you want to start SCRIPT from one computer and then make it work on all others ??not exatly i have all the same defense across them just wanted to move this file then to the desktop then have it run.

4587.

Solve : .cmd file creates unnecessary character?

Answer» OKAY - NEVER MIND.
4588.

Solve : Extracting a string from logfile?

Answer»

Hi Folks,

From the following logfile I am trying to extract "NetWorker savegroup: (notice) index completed" to a variable - I have tried lots of variations using find & findstr but have had no success. Can anybody point me in the right direction to achieve this.

Mar 27 14:36:18 moses: NetWorker savegroup: (notice) index completed, Total 1 client(s), 1 Succeeded. Please see group completion DETAILS for more information.
Mar 27 14:36:18 moses: Succeeded: moses
Mar 27 14:36:18 moses: saveset moses:C:\DELL: percentage of inactive files by count: 50.00, by space: 39.61
Mar 27 14:36:18 moses: Start TIME: Fri Mar 27 14:35:51 2009
Mar 27 14:36:18 moses: End time: Fri Mar 27 14:36:18 2009
Mar 27 14:36:18 moses: --- Successful Save SETS --- Mar 27 14:36:18 moses: * moses:Probe savefs moses: succeeded.
Mar 27 14:36:18 moses: moses: C:\DELL level=full, 401 KB 00:00:04 16 files

Many Thanks,
Matt.
you COULD try this script:
Code: [Select]@echo off
for /f "tokens=*" %%a in ('findstr "NetWorker savegroup: (notice) index completed" logfile.txt') do set returnstring=%%a
echo %returnstring%
pause

Hope this Helps
,Nick(macdad-)

4589.

Solve : Logon & Logoff info with %TIME% (Excel format issue)?

Answer»

I TRIED to read up on some of the more current threads before posting this, but didn't see anything similar enough. I'm new at a job and inherited this issue (so I'm not even sure it's the best method for achieving this goal).

There are two batch files:

First: echo Logon %COMPUTERNAME%,%USERNAME%,%DATE%,%TIME% >> \\server\logon$\UserLogon.csv

Second: echo Logoff %COMPUTERNAME%,%USERNAME%,%DATE%,%TIME% >> \\server\logon$\UserLogon.csv

Issue: The file is opened in EXCEL and the Time column is convered to time. The values are different. Logon formats as "9:02:44.06" and Logoff formats as "12:47:06 AM" I need to subtrack the times so they need to be in the same format.

Perhaps this is an Excel issue, and not a batch issue, but is there any modifications I can make to the script to get the data to format consistently? Also, is there anyway to capture the INFORMATION with a single batch file, or to get teh difference in logon and logoff time automatically?

Thanks in advance.No need since you are IMPORTING into Excel. Excel should take care of the formatting for you automatically so you just need to subtract the times.I believe the information from the .cvs file was imported into Excel and that a time format applied to those values. Instead of using a formatting option which took into account the AM/PM information, it APPEARS to have been formated into a simple hh:mm:ss. This information was then saved, which overwrote the raw data. Additional data is then appended to the end of the file and process starts all over again.

I think I just need to go back and start from scratch, applying the correct time format to the data.

Thanks.

4590.

Solve : how to check permissions??

Answer»

Hi all,

I need to check that write permission are available on a pen drive and keep looping untill they are.

Its basically a protected pen drive that will only allow access when the password has been entered so
i want to sit and wait untill the user enters the password and when they do (ie write permissions are available)
i want to copy files.

anyone any ideas on a loop that will continue to check permissions?

thanks

Sorry, but I don't understand what you are trying to do.....

How is the Flash Drive protected?

What are you trying to accomplish?Something fishy here! Such a scheme could be used for abuse. Surely if "the user", owner of a protected pen drive, having entered a password, wants to copy files on to that drive, they can (and should) arrange this for themselves? I cannot think of a legitimate reason for needing to do this.

Quote

want to sit and wait untill the user enters the password

You do, do you? I was going to ask why do you want to do this, Mister One Post, but on reflection whatever your reply MIGHT be I don't think we should provide a solution in view of the potential for abuse.


woooo, ok i can SEE where you guys are coming from but this isnt for malicious purposes.
I mean why would i of told you what i wanted to do if it was, i would of just made up some other crap.

The scenario is basically the user (which are many using the same key fob) insert the key and run a batch file.
the batch runs the keys log on program (kept on the key) and when the user enters the key fobs password the batch file
copies the up to date VERSION of files from a server to the fob.

Its just to simplify the copy process for the user and remove errors.

Its one of my FIRST batch programs hence the 1 post, cheers.Well, how do you think a person might check if a medium was write enabled?
Try writing to it and see if it is successful.
but i don't know how you do this in a batch file.

i have only really used .net so i don't know whats even possible using batch files, hence why i asked here.

you can use the && and || operators.

Hilarious!! what a friendly forum, think ill hang around.....
Quote from: BatchHelp2009 on March 27, 2009, 08:43:00 AM
Hilarious!! what a friendly forum, think ill hang around.....


It's a responsible forum. You didn't get what I was DRIVING at, did you? You might or might not have honest intentions, but this is a forum on the world wide web. That means if I wrote your script for you any dumb script kiddie can surf by and pick up a ready made script to flood pen drives with whatever he wants as soon as they become unprotected.

Anyway, with the transfer out of the user's control, how do you know they won't pull the pen drive out half way through and corrupt the filesystem?

Quote
I mean why would i of told you what i wanted to do if it was, i would of just made up some other crap.

Oh right! "If I was a liar I wouldn't be telling you the truth, I'd have made up some lie, so you see you've got to believe me."

"would of"
Quote from: BatchHelp2009 on March 27, 2009, 08:27:11 AM
i have only really used .net

Explains it all. Well, not really. I just wanted to pick on this.
4591.

Solve : if exist?

Answer»

hello

you know that we USE if exist to look if a folder or a file exist.

what if I want to see if a registry key exist

thanks you can use a TOOL like reg.exe. do a query to the registry with it, then check for errorlevel. (or you can grep for expected error MESSAGES that reg.exe gives)THANK you M.r ghostdog74 for replaying

but I don't know how to use error level

and I want to do that by CMD script not by any other tools

thanks again

4592.

Solve : Counter in for loop doesn't increment?

Answer»

To all,
I need to run a batch script to read in an input file and then print out how many lines it read. The problem is the counter doesn't INCREMENT. It keeps resetting back to zero but after the loop, it gets the RIGHT counter but just not inside the loop.

Please help. Thanks.

Here's the script:

set x=0
for /f %%i in (f.txt) do (
echo A, %x%
set /a x=x+1
echo %%i
echo B, x=%x%
)
echo C, x=%x%
:END

This is the output:

A, 0
hostname1
B, x=0
A, 0
hostname2
B, x=0
A, 0
hostname3
B, x=0
C, x=3Quote from: april on March 27, 2009, 05:13:34 AM

To all,
I need to run a batch script to read in an input file and then print out how many lines it read.
basically, you just need a LINE count of the file correct?
you can use one of these methods
1) use a unix tools like wc, gawk
Code: [Select]# wc -l < file
check out the link in my sig to download. (coreutils)
2) if you have constraints about "installing" tools, you can use vbscript
Code: [Select]Dim o
o=0
Set objFS = CreateObject("Scripting.FileSystemObject")
strFile= "C:\test\file.txt"
Set objFile = objFS.OpenTextFile(strFile,1)
Do Until objFile.AtEndOfLine
strLine = objFile.ReadLine
o=o+1
Loop
WScript.Echo "number of lines: ",o
3) or you can use find
Code: [Select]find /c /v "" file
Oh God! Another "how do I make this batch work?" question answered by "Get a port of a Unix util".

Heaven forbid we should actually answer the *censored* question!

April, due to the way that cmd.exe expands variables at runtime, an ordinary variable which is set inside brackets (parentheses) such as in a loop or an extended IF statement, will expand to a blank.

You need to know about "delayed expansion". You enable it by putting this line before the loop

Code: [Select]setlocal enabledelayedexpansion
Then inside the loop you use exclamation marks instead of percent signs for those variables created or modified inside the loop. You can use percent signs for them after the loop has finished. So here is your code rewritten a bit


Code: [Select]setlocal enabledelayedexpansion
set x=0
for /f %%i in (f.txt) do (
echo A, !x!
set /a x=!x!+1
echo %%i
echo B, x=!x!
)
echo C, x=%x%
:ENDQuote from: DIAS DE verano on March 27, 2009, 08:09:08 AM
Oh God! Another "how do I make this batch work?" question answered by "Get a port of a Unix util".
as long as OP has no constraints, i don't think there's a problem with that. Quote from: ghostdog74 on March 27, 2009, 08:23:40 AM
as long as OP has no constraints, i don't think there's a problem with that.

I know you don't.
4593.

Solve : How to use TYPE command?

Answer»

I have a problem where php files have the wrong linefeed after uploading them via ftp. I'm looking for a way to do a batch convert on a nmber of files to fix this problem. I found this article http://en.wikipedia.org/wiki/Newline#Conversion_utilities that says that can be done by typing in Code: [Select]TYPE unix_file | FIND "" /V > dos_file
I tried that but it didn't work. I then tried variations and ended up with Code: [Select]TYPE dos_file
and that still doesn't work.

I'm doing this from a cmd prompt in XP. When I press enter, the line is just displayed again - no output of any kind. I am using the full path for the file. Would somone please point out what I am doing wrong or how to properly run such a command?have you tried:

Code: [Select]type unixfile.txt > dosfile.txt
just without FIND command?Thanks for the reply. I see what I was doing wrong. I only listed the output file in the command. I've changed that now and added back in the original command to edit the file. It does create the new file and the conversion to dos has been done but the file gets truncated. The original file is over 1,000 line but the new file is only 60 lines. Those 60 lines match the original so it is at least reading it correctly, up to a point. These are php files, if that matters. Does anyone know why this may be failing?Quote from: alter on March 23, 2009, 12:04:18 PM

I have a problem where php files have the wrong linefeed after uploading them via ftp. I'm looking for a way to do a batch convert on a nmber of files to fix this problem. I found this article http://en.wikipedia.org/wiki/Newline#Conversion_utilities that says that can be done by typing in Code: [Select]TYPE unix_file | FIND "" /V > dos_file

that's code is working fine here. i tested out this .php file i obtain from net. when viewed in notepad, the line break show as SOMETHING like rectangle character. (ascii 10). after running the command type|find, the line break is properly fixed as ascii13+ascii10

character 13 is carriage return, character 10 is line feed.

DOS uses crlf, Unix uses lf, and mac uses cr.

An alternative method could be to upload the files using binary mode rather then text.Quote from: Reno on March 23, 2009, 11:16:07 PM
that's code is working fine here. i tested out this .php file i obtain from net. when viewed in notepad, the line break show as something like rectangle character. (ascii 10). after running the command type|find, the line break is properly fixed as ascii13+ascii10

I tried debug filename.php -d, using the full path for the filename. Right after pressing enter, it days file can't be found and then hangs. A ctrl z won't end it. Quote from: BC_Programmer on March 23, 2009, 11:34:34 PM
character 13 is carriage return, character 10 is line feed.

DOS uses crlf, Unix uses lf, and mac uses cr.

An alternative method could be to upload the files using binary mode rather then text.
I've been fighting this problem for over a year. Others have suggested forcing the upload in ascii as well as binary. I've tried both ways but it dosn't make a difference. The problem is that sometimes I may have forty files with this problem mixed in with other files that are fine and of different types. So forcing an upload, even if that worked, would require more work than fixing each file manually and then uploading normally. I tried using sed to do it but can't get that to work either (nor could the sed groups I asked in). Then I ran across this command and thought my problems were solved. But I'm beginning to think this is a problem without a solution.This is one solution:http://download.cnet.com/Unix2DOS/3000-2381_4-10488164.html
Thanks for the link. I wasn't AWARE of that program. It won't help since it only handles one file at a time but I did find one with the same name that says it runs in batch mode but it doesn't work as described. But that gives me something to search for. If two of these exists, there are PROBABLY others so I will keep looking. Thanks for all of the help. It did make a difference and I appreciate it.
Sometimes solutions can be found outside of the box I just wanted to post the solution I found since it may help others. There is a free shell program named Flip - http://ccrma-www.stanford.edu/~craig/utility/flip/I added it as a button to my file manager app so I just NEED to select the files in question, click that button and it converts and uploads the files. I wouldn't have found it without the suggestions here so I truly appreaciate that. This has ended a very long battle.
4594.

Solve : Help with DOS command?

Answer»
HI all,

Recently been assigned to understand some DOS command in order to enhance the batch files running in my company server.
Below is a string of commands which i seriously do not understand:

set APP_C=%1
set JOB_C=%2
JAVA -Xmx2M -Dant.home=ant -Dapp=%APP_C% -Djob=%JOB_C% -cp sny\lib\ant.jar;ant\lib\ant-launcher.jar;ant\lib\xml-apis.jar; ant\lib\xercesImpl.jar; org.APACHE.tools.ant.Main -buildfile RUN.xml %3

Erm, can I understand what does all these means? It seriously look greek to me. ='(Code: [Select]java -Xmx2M -Dant.home=ant -Dapp=%APP_C% -Djob=%JOB_C% -cp sny\lib\ant.jar;ant\lib\ant-launcher.jar;ant\lib\xml-apis.jar; ant\lib\xercesImpl.jar; org.apache.tools.ant.Main -buildfile run.xml %3
This starts the Java complier.

Seems to run Apache, which is a DATABASE prog.

Code: [Select]set APP_C=%1
set JOB_C=%2
This just sets "APP_C" to the first parameter, and sets "JOB_C" to the second parameter.

Since this is on your company server i suggest that you don't mess with it until you learn some more on this.

Hope this Helps
,Nick(macdad-)
4595.

Solve : Error Code Issue?

Answer»

I have a batch file where I call a .exe

Im TRYING to pickup the errorlevel returned from this but the .exe creates a popup window that says the error code with an OK button. After clicking ok the %errorlevel% is returning as 0.

1. Is there a way to suppress the popup? I dont know if there are codes like /Y for it or not.
2. How can I pickup the errorlevel from this .exe? If I cant get the errorlevel then I simply want to suppress the popup and return wether or not it completed successfully regardless of the error code.

ThanksSuppressing the Pop up will likely not get answered here as for it can be used for improper malicious usage, even if your intent is harmless.

What is the EXE that you are running and what does it do?Nothing Malicious here.

The exe is runmac32.exe which is a Cognos executable that swaps a data connection to a powercube for the product.

My intent here is to error trap if the swap is succesful but the command line

"D:\Program Files\cognos\cer4\bin\runmac32.exe" "D:\RM Bat Files\Cube.mac"

Produces a little popup that says "Error Code XX" with an OK button. I need to get passed the OK button and pick up wether or not the command line executed successfully.

Thanksmrobby, post your batch code here.
along with a screenshot of the errormessage popup+successful popup.REM Copy model to local directory for cube build
copy "\\ixca-fs1\dfs\common\cognos\bi\cubes\RM Cubes\Ixia_Forecast.pyi" "\\ixca-cogdev\RM Cube Model Temp\Forecast.pyi" /Y
IF %ERRORLEVEL%==1 THEN GOTO CopyFail

This is the code I want to error check
"D:\Program Files\cognos\cer4\bin\runmac32.exe" "D:\RM Bat Files\Build_Forecast_Cube.mac"



REM Delete local copy of the model used to build the cube
del "\\ixca-cogdev\RM Cube Model Temp\Ixia_Forecast.pyi"

REM Delete all files in the PRODUCTION cube folder
del "\\ixca-fs1\dfs\common\cognos\bi\cubes\RM Cubes\Finance Forecast\ixia_forecast*.mdc"

REM create a timestamp variable
set _date=%date:~10,4%%date:~4,2%%date:~7,2%
set _timestamp=%_date%
set _time=%time:~0,2%%time:~3,2%%time:~6,2%
set _yesterday=%date:~10,4%%date:~4,2%%date:~7,2%-1

REM change any space to a zero
set _time=%_time: =0%

set _timestamp=%_timestamp%%_time%

REM Copy previously built cube to production folder with time stamp appended to end of the name
copy "\\ixca-fs1\dfs\common\cognos\bi\cubes\rm cubes\forecast.mdc" "\\common\cognos\bi\cubes\RM Cubes\Forecast\forecast%_timestamp%.mdc" /Y

REM Run cubeswap utility to update cognos connection to new cube
D:
cd "\Program Files\Cognos\C8\webapps\utilities\cubeswap"
call cubeSwap.bat -dispatchername="http://ixca-cogdev:9300" -datasource="RM_PowerPlay_Opex" -url="http://ixca-cogdev:9300/p2pd/servlet/dispatch" -windowscube="\\ixca-fs1\dfs\common\cognos\bi\cubes\RM Cubes\Forecast\forecast%_timestamp%.mdc" -namespaceid="Default" -username="" -password=""
net send ixca-rmeyers "Cognos Forecast Powercube was updated successfully"
goto ending


:CopyFail
net send ixca-rmeyers "The forecast powercube failed to build due to a copy failure of the model to the temp directory"
goto ending

:ending

[attachment DELETED by admin]There is no popup if the command executes successfullyi dont see any runmac32.exe calling here, so my guess is it's inside the cubeswap.bat.

create a new file supress.vbs
Code: [Select]appname="build_"
wsh.sleep 10000
set a=createobject("wscript.shell")
if a.appactivate(appname) then
wsh.sleep 100:a.sendkeys "~"
else
wsh.echo "failed to activate"
end if
play with the wsh.sleep 10000 command.

then modify the batch file where it contain the runmac32.exe line to :
Code: [Select]start "" %comspec% /k "cscript//nologo supress.vbs"
runmac32.exe blablba

if the above not working, i was thinking to use WMI to monitor the thread for threadwaitreason=13, but i am stuck to know which one of the thread is msgbox.
when the error MSG appears, does the application quit after you click OK?

notes: plz edit your post above and remove the username/password.This part of the code is where I call runmac32.exe. Cubeswap.bat works as intended and is a separate process.

Quote from: mrobby on March 25, 2009, 10:01:00 AM


This is the code I want to error check
"D:\Program Files\cognos\cer4\bin\runmac32.exe" "D:\RM Bat Files\Build_Forecast_Cube.mac"


ah, somehow i miss that red coded line.

so, have you create supress.vbs? and modify the batch code to :
Code: [Select]start "" %comspec% /k "cscript//nologo supress.vbs"
"D:\Program Files\cognos\cer4\bin\runmac32.exe" "D:\RM Bat Files\Build_Forecast_Cube.mac"

change /k to /c when everything run smooth.check also the manual or HELP file of runmac32.exe. It may (or may not) provide details on how to put it in "quiet" mode.
4596.

Solve : How i can rewrap text??

Answer»

Hi all!!
How I can use file .bat rewarp text in file .txt but don't trim word (only trim space) with width i like
Example:

1. katy perry - thinking of you.mp3
2. kelly clarkson - my life, would suck without you 2009.mp3
3. akon and kardinal offishall and colby o donis - beautiful.mp3

to

1. katy perry - thinking of
you.mp3
2. kelly clarkson - my life,
would suck without you
2009.mp3
3. akon and kardinal offishall
and colby o donis -
beautiful.mp3

with 30 width

Thanks,If possible, you can use a higher level language, such as Python, with its textwrap library
Code: [Select]IMPORT textwrap
for line in open("file"):
print '\n'.join(textwrap.wrap(line,30))
I don't know use python. When i install python 3.0 and use your code.
Quote

import textwrap
for line in open("file"):
print '\n'.join(textwrap.wrap(line,30))
Program print: "SyntaxError: invalid syntax" I use *.txt as "file" (I do it with my computer in house)
Can you teach me?

-I have other problem, I can't install any programming language on computer in my company. I use Wondow XP.Quote from: Star-Fire on March 26, 2009, 09:18:38 PM
I don't know use python. When i install python and use your code. Program print: "SyntaxError: invalid syntax" I use *.txt as "file"
Can you teach me?
the code is only used for ONE text file. if you want more that one text file, do it like this
Code: [Select]import textwrap,glob
for file in glob.glob("*.txt"):
for line in open("file"):
print '\n'.join(textwrap.wrap(line,30))

Quote
I have other problem, I can't install any programming language on computer in my company. I use Wondow XP.
if you can use USB, here's Portable python. Otherwise, you can just try to use vbscript. In that case, you would have to do a little bit of programming.
1) Open the file
2) Get each line, check total number of character
3) Divide them up by 30, which will give you how many lines there will be broken up.
4) Use a loop, do a substring , getting 30 characters each time...print them out , each time followed by a newline.
5) .......

Can I see your code for vbscript I want it can work more that one text file.Code: [Select]Set objFS = CreateObject("Scripting.FileSystemObject")
strFile= "C:\test\file.txt"
Set objFile = objFS.OpenTextFile(strFile,1)
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
strLengthLine = Len(strLine)
For i=0 To CInt(strLengthLine /30)
WScript.Echo Mid(strLine,1,30)
strLine= Mid(strLine,31)
Next
Loop
i would expect you to read up on how to use vbscript. Here's a linkit's not working as expected
Code: [Select]1. katy perry - thinking of yo
u.mp3
2. kelly clarkson - my life, w
ould suck without you 2009.mp3

3. akon and kardinal offishall
and colby o donis - beautiful
.mp3

requirement 1:
Quote from: Star-Fire on March 26, 2009, 11:01:44 AM
1. katy perry - thinking of
you.mp3
2. kelly clarkson - my life,
would suck without you
2009.mp3
3. akon and kardinal offishall
and colby o donis -
beautiful.mp3

requirement 2:
Quote from: Star-Fire on March 26, 2009, 09:45:38 PM
Can I see your code for vbscript I want it can work more that one text file.
this should be easy.

base on your latest posts history, i have doubt that you can write code as per requirement.Quote from: Reno on March 27, 2009, 12:17:02 AM
it's not working as expected
works for me. OP just needs to tweak it a little.
Code: [Select]C:\test>cscript /nologo test.vbs
1. katy perry - thinking of yo
u.mp3
2. kelly clarkson - my life, w
ould suck without you 2009.mp3

3. akon and kardinal offishall
and colby o donis - beautiful
.mp3
can you actually write code? the OP is asking a really simple script:
1. read more that one text file, eg. read all the txt file in a folder, or read all the txt file based on argument passing
2. rewarp text in file .txt but don't trim word (only trim space) with specified width (eg. 30 width).

the code you posted is rather a generic code to read file.

example of what output the OP ask:
string=1. katy perry - thinking of you.mp3

incorrect ouput:
1. katy perry - thinking of yo
u.mp3

correct output:
1. katy perry - thinking of
you.mp3
Quote from: Reno on March 27, 2009, 12:50:30 AM
can you actually write code?
what's the matter with you? do you seriously doubt i can't code? I am also not obliged to provide FULL solutions every time i post. I believe i have provided enough for him to follow through and do it on his own. If you want, you can do that, but i think you will not be helping him LEARN at all. So would you please get off my back?
Quote from: ghostdog74 on March 27, 2009, 12:59:24 AM
what's the matter with you? do you seriously doubt i can't code? I am also not obliged to provide FULL solutions every time i post. I believe i have provided enough for him to follow through and do it on his own. If you want, you can do that, but i think you will not be helping him learn at all. So would you please get off my back?


Now now boys CALM down
4597.

Solve : Input hiding (different from password hiding)?

Answer»

In batch, a user will be entering a password to allow them access, but I want it so someone looking over their shoulder can't see the password (sortof like...not sort of like, exactly like password masking in VB)...

I saw this a while ago, but I can't find it anymore .

I can use a 3rd party program, but it has to be a very small file size (as small as possible!)Here Code: [Select]@ECHO off & setlocal %CheckPWD {[emailprotected] 2008-12-12}%

echo Password:
call :CheckPWD p1 123456 *
echo.
if errorlevel 1 (echo %p1% - No) else (echo %p1% - Yes)

echo.

echo Password:
call :CheckPWD p2 123456
if errorlevel 1 (echo %p2% - No) else (echo %p2% - Yes)

pause & goto :eof






:CheckPWD
setlocal & if "%~2"=="" exit /b 1

for /f "tokens=1 delims=:" %%a in ('findstr /nrc:"^e100 B7 2A 80" "%~f0"') do set /a n=%%a-1
more /e +%n%<"%~f0" | debug>nul

if "%~3"=="" x>nul
if "%~3" neq "" set c=%~3 & call set "c=%%c:~0,1%%"
if "%~3" neq "" x %c%

for /f %%a in ('x -o') do set "p=%%a"

endlocal & set "%~1=%p%" & del x.com & if "%~2"=="%p%" (exit /b 0) else (exit /b 1)

e100 B7 2A 80 3E 80 00 00 74 22 80 3E 80 00 02 75 06
e110 8A 3E 82 00 EB 15 83 E0 00 8E D8 80 3E 00 02 00
e120 74 6A BA 01 02 B4 09 CD 21 EB 61 83 E6 00 8E C6
e130 80 E4 00 CD 16 8A D8 80 FB 1B 75 08 26 80 26 00
e140 02 00 EB 48 80 FB 0D 74 37 80 FB 08 75 1A 83 FE
e150 00 74 DD B2 08 B4 02 CD 21 B2 20 B4 02 CD 21 B2
e160 08 B4 02 CD 21 4E EB C8 80 FB 21 72 C3 80 FB 7E
e170 77 BE 8A D7 B4 02 CD 21 26 88 9C 01 02 46 EB B0
e180 26 C6 84 01 02 24 26 C6 06 00 02 24 B8 00 4C CD
e190 21
nx.com
rcx
91
w
qQuote from: macdad- on April 16, 2009, 08:04:03 PM

Here
Thanks macdad, but I'm afraid that won't work (or I don't know how it could work). What I happens is the user enter's their username, then their password. If the username and password don't match a line in a file, then the user tries again, or gives up...Is there a way that it can MASK the input (like in visual basic), instead of doing it letter by letter?I believe it may be possible in VBScript.Quote from: macdad- on April 18, 2009, 03:22:40 PM
I believe it may be possible in VBScript.
I know absolutely nothing (usefull) in VBScript...can you show me how to/make it?I'm not knowledgeable in VBScript either.

I think Ghostdog is good with it though.

Quote from: macdad- on April 18, 2009, 04:37:11 PM
I'm not knowledgeable in VBScript either.

I think Ghostdog is good with it though.


So, should I post this in "Computer Programming"?Your decision.Quote from: macdad- on April 18, 2009, 04:57:49 PM
Your decision.
Just did. Thanks for your help macdad-!Quote from: macdad- on April 18, 2009, 04:37:11 PM
I'm not knowledgeable in VBScript either.

I think Ghostdog is good with it though.
ghostdog will only suggest you:
- installs gawk, see my sig
- if you are able to download stuffs, you can use sed (check my sig for link).
- if you want to do programming/batching on windows, get a real programming language.
- Switch to *nix then.
-there are abundance of tools out there you can use. the unix Find command , which is ported to windows makes this kind of task seem trivial.
- and many moreThat looks very hard to do. What is the ovjective?
You want the user to type in a passwrod at a prompt from inside a batrch?
The input must not have echo or just *** maybe?
The batch file can retrieve the password from some place the average user would not guess. Right?Quote from: Reno on April 18, 2009, 10:51:39 PM
ghostdog will only suggest you:
for your info, i do GIVE solutions in vbscript sometimes. see here.

Quote
- Switch to *nix then.
don't put words in my mouth.
as for your other comment, i can only say, I advocate using right tools for the job ->> productivity.

@helpmeh, see your other post and also here


Quote from: Reno on April 18, 2009, 10:51:39 PM
ghostdog will only suggest you:
- installs gawk, see my sig
- if you are able to download stuffs, you can use sed (check my sig for link).
- if you want to do programming/batching on windows, get a real programming language.
- Switch to *nix then.
-there are abundance of tools out there you can use. the unix Find command , which is ported to windows makes this kind of task seem trivial.
- and many more

He surpassed himself in the other thread about this topic started by Helpmeh, by posting a link to Experts Exchange (plus the inevitable Perl script)

gawk, or dawk?


Quote from: Dias de verano on April 19, 2009, 02:57:37 AM
He surpassed himself in the other thread about this topic started by Helpmeh, by posting a link to Experts Exchange (plus the inevitable Perl script)

gawk, or dawk?



so do you have a problem with that? or are you purposely being irritating? take a hike. (or take your medicine if you haven't)
4598.

Solve : Listing Seven Character Text Files on Root Drive?

Answer»

Quote from: gh0std0g74 on May 09, 2009, 03:32:45 AM

how do you define batch? give me a real answer
Quote from: gh0std0g74 on May 09, 2009, 03:34:26 AM
me too.

Grow up for God's sake.Quote from: kpac on May 09, 2009, 03:35:19 AM
Grow up for God's sake.
you can't answer me? then where's is that justification that what i do is wrong?Quote from: gh0std0g74 on May 09, 2009, 03:36:39 AM
you can't answer me? then where's is that justification that what i do is wrong?

Exactly I can't answer you, because I don't know batch. But I do know how to run a forum.Quote from: gh0std0g74 on May 09, 2009, 03:32:45 AM
how do you define batch? give me a real answer

In DOS, OS/2, and Microsoft Windows, a batch file is a text file containing a series of commands intended to be executed by the command interpreter. The OP mentioned a C: drive, so it's a pretty fair bet he or she is using one of these. It is also a fair bet, since the OP appears to be seeking the solution to a school assignment, and from a careful reading of the question, that the desired outcome is to demonstrate competence in using fairly simple features, such as command output redirection, DIR switches such as /W and /S and wildcards. I think the assignment is more likely to find FILES of 7 characters or less in the filename.


Quote from: kpac on May 09, 2009, 03:37:55 AM
Exactly I can't answer you, because I don't know batch.
wow, you do not know batch, BUT you can tell what's right or wrong? gimme a break.

Quote
But I do know how to run a forum.
no you don't. If you are really running this forum, as in doing the administration/design etc..you would state clearly that anything other than batch are not allowed, only then I will not post in VBscript or any other languages i know.Wow, a FLOOD of TOPIC reports...

Dias, Ghostdog, settle this elsewhere. That's what PMs are for.

Topic Closed. If anyone WANTS this reopened for any reason, please PM me.


Kpac is right in one thing. He doesn't go around trying to boost his post count with useless remarks.
4599.

Solve : Send data over ip ... if possible in dos ??

Answer»
hi guys! if possible to send FILE to the over ip in dos ?

send & receve file on dos ! like client Server.i think you will have to make it yourself, that's what i did... but my app was sending text instead of FILES, and was buggy like Quote from: Deadly D on May 25, 2009, 04:26:05 AM

hi guys! if possible to send file to the over ip in dos ?

send & receve file on dos ! like client Server.
you will have to use tools already made for that , like ftp, sftp, netcat. etc.
Or you can COOK up your own code using socket PROGRAMMING. Languages like Python, or PERL enables you to use socket libraries to program client/server applications with ease.
4600.

Solve : Replacing single lines in files?

Answer»

is it possible to use findstr to get a line is a file. then REPLACE that line with and edited line?
like:
Code: [Select]findstr "line that i want to find" file.txt | replace "line that i want to find" "new line" file.txt
is there something like this?
Quote from: BatchFileBasics on May 24, 2009, 09:38:01 PM

is it possible to use findstr to get a line is a file. then replace that line with and edited line?
like:
Code: [Select]findstr "line that i want to find" file.txt | replace "line that i want to find" "new line" file.txt
is there something like this?

findstr is not the tool to edit files. See here for few examples i gave to replace TEXT in files. if you want to try the vbscript, do some changes
Code: [Select].....
strLine = objFile.ReadLine
strLine=Replace(strLine,"SEARCH","replace")
wscript.Echo strLine
.......
ahh.
thank you very much. it took a LITTLE bit for me to COMPLETELY understand but now i know.
Thank you very much gh0std0g