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.

5651.

Solve : BATCH FILE + sleep command???

Answer»

I have a batch file, and part of it, the user has the choice to either, shutdown, hibernate, logoff or sleep. I have all of the commands except for the sleep command...is there one? I have been un-able to find one
I am using Windows 7shutdown
Shutdown.exe -s -t 00

restart
Shutdown.exe -r -t 00

logoff
Shutdown.exe -l

sleep
rundll32.exe powrprof.dll,SetSuspendState 0,1,0

lock
Rundll32.exe User32.dll,LockWorkStation
Quote from: behzad-007 on August 11, 2011, 02:43:32 AM

@echo off
@echo select number
@echo.
echo 1.shutdown
echo 2.restart
echo 3.logoff
echo 4.sleep
echo 5.lock
@echo.
set/p ch="your choise >"
if %ch%==1 goto shutdown
if %ch%==2 goto restart
if %ch%==3 goto logoff
if %ch%==4 goto sleep
if %ch%==5 goto lock
:shutdown
Shutdown.exe -s -t 00
:restart
Shutdown.exe -r -t 00
:logoff
Shutdown.exe -l
:sleep
rundll32.exe powrprof.dll,SetSuspendState 0,1,0
:lock
Rundll32.exe User32.dll,LockWorkStation
That's not how you spell "choice", and what happens after the set /p line if the user just presses ENTER? Or anything other than 1 to 5?

Hi behzad-007,

Since OP is using Win7 other than XP, I think it's better to use choice command. Because it's COMPLICATED to ensue user's legal input when using set /p command.
Quote from: CN-DOS on August 14, 2011, 05:50:31 AM
it's complicated to ensue user's legal input when using set /p command.

No it isn't. At least not in this case. The use of quotes around the VARIABLES will avoid an error after a null input and a final GOTO after the tests for legal characters can redirect the user to make a further attempt.

Code: [Select]:loop
set/p ch="Your choice [1,2,3,4 or 5] >"
if "%ch%"=="1" goto shutdown
if "%ch%"=="2" goto restart
if "%ch%"=="3" goto logoff
if "%ch%"=="4" goto sleep
if "%ch%"=="5" goto lock
echo.
echo Enter 1,2,3,4 or 5 only!
echo.
goto loop


Quote
No it isn't. At least not in this case.

Yes, I agree. We do have METHOD to filter the input. But not your code. Did you tried input only a double quotation mark "Quote from: CN-DOS on August 14, 2011, 06:12:05 AM
Yes, I agree. We do have method to filter the input. But not your code. Did you tried input only a double quotation mark "

That's a good one.
The sleep command that "behzad-007" gave me (rundll32.exe powrprof.dll,SetSuspendState 0,1,0) hibernates my computer! Is this ment to happen??
Can SOMEONE please help me...the sleep commands I have been given hibernate my computer. I am running Windows 7They haven't been back in 7 years...Quote from: athman8 on April 04, 2018, 07:10:16 AM
I use a batch file to start up a few of the programs I need running in the background. Up until now, I had used the pause command to execute it after some of the other start-ups finished. I would prefer to use the wait or sleep commands but they do not appear to be included in Windows 7.Anybody know how to put those commands back in, or a different method that achieves the same results?
Timeout
5652.

Solve : Unable to ping a particular website?

Answer»

Using my LG Rebel phone running Android 5.1.1, I was able to ping the site. The site is ravib.com, the one posted. But, I was using a phone and not a PC. Here is the screenshot

[attachment deleted by admin to conserve space]Not unusual.
Reference:
https://en.wikipedia.org/wiki/Ping_(networking_utility)
Quote

In case of error, the target host or an intermediate router sends back an ICMP error message, for example "host unreachable" or "TTL exceeded in transit". In addition, these messages include the first eight bytes of the original message (in this case header of the ICMP echo request, including the quench value), so the ping utility can match responses to originating queries.
But that does not really tell you what is wrong with the site. It just tells you that the ping does not work.

The objective is to see if the web site is up and doing normal HTML stuff. -Right?
When piing does not work, you can use another kind of tool to verify the web site is working normally. You can find many in a Internet search.

Verify website is online without ping.

https://www.uptrends.com/tools/uptime
https://www.pingdom.com/free
http://dnscheck.pingdom.com/
https://community.spiceworks.com/topic/514573-connectivity-check-without-ping-test

Not found in above search was:
Network-Tools

This is my favorite way to see if either the host server or my own website is down. It gives a detailed trace and also provides DNS information and WHOIS details. Quote from: Coco423 on March 02, 2018, 11:40:40 AM
Using my LG Rebel phone running Android 5.1.1, I was able to ping the site. The site is ravib.com, the one posted. But, I was using a phone and not a PC. Here is the screenshot

Screenshot clearly shows that there was no ping reply. 100% packet LOSS.Quote from: Coco423 on March 02, 2018, 11:40:40 AM
Using my LG Rebel phone running Android 5.1.1, I was able to ping the site. The site is ravib.com, the one posted. But, I was using a phone and not a PC. Here is the screenshot
I guess you do not understand how networking works. Your ping clearly shows 100% packet loss.
Code: [Select]H:\>ping google.com

Pinging google.com [172.217.6.110] with 32 bytes of data:
Reply from 172.217.6.110: bytes=32 time=8ms TTL=50
Reply from 172.217.6.110: bytes=32 time=8ms TTL=50
Reply from 172.217.6.110: bytes=32 time=8ms TTL=50
Reply from 172.217.6.110: bytes=32 time=8ms TTL=50

Ping statistics for 172.217.6.110:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 8ms, Maximum = 8ms, Average = 8ms

H:\>ping ravib.com

Pinging ravib.com [69.172.237.220] with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 69.172.237.220:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

H:\>
Oh. Sorry. That was the first time I tried to ping, now know ping failed. Good to know. Thought packet lss meant something. Follow the ping...the ping reveals all...

Keep trying.Quote from: PATIO on March 02, 2018, 06:37:48 PM
Follow the ping...the ping reveals all...

Keep trying.
I thought I was supposed to follow the white rabbit.1 pill MAKES you larger...Quote from: patio on March 02, 2018, 07:46:56 PM
1 pill makes you larger...

Yeah, I get those emails too Yeah, pssh, "This pill can make you larger". Seriously? I'm not a dwarf so why are you telling me this?It's from White Rabbit...just so you know.athman8 Welcome Aboard...

You should start a new Topic so it can recieve the proper attention...Quote from: athman8 on April 04, 2018, 07:12:14 AM
I have encountered an issue recently that I am unable determine the cause of. There is a website I needed to access and was unable to access it so I called the customer service department of the website's organization and they told me after some troubleshooting to TRY to open the website on a different computer. This suggestion worked. I was able to access it with no issue on another Windows 10 computer. In fact, I was able to access this website on my smartphone and a Macintosh computer that are all connected to the same network.
Your comments have nothing to do with this question. We are talking about getting a PING response. Not whether the website loads in your browser. He's new...

Go easy squash.... OK...apparently you didnt' get the hint....Posting priviledges restricted.

patio.
5653.

Solve : Bootable Dos 6.22 CD?

Answer»

Is it possible to make a Bootable Dos 6.22 CD? I want to make Bootable cd with Dos 6.22 and all the programs I want on it to. That way I can show other what Dos look like. I would after it booted it would be on Floppy a: drive. I try to make it with PowerISO but couldn't do it or I didn't know how.

Any help would be great. FREEDOS is the best solution for this vs putting DOS 6.22 on a CD. FREEDOS you boot from CD and it acts exactly like DOS. Very little is unsupported. Even DOS games can run through FREEDOS. Additionally FREEDOS is free and no issues with EULA of the Microsoft license.I downloaded all 5 of there files. Which one will boot up like Dos because I don't use Windows. I use Linux.FREEDOS should bring you to a prompt when loaded and it will load direct from CD. No Windows or GUI environment. Additionally FREEDOS's internals were built off of Linux from what I have been told. https://en.wikipedia.org/wiki/FreeDOSWorth noting that genuine (Microsoft) MS-DOS version 6.22 (or any other version) is a copyright product and also all Microsoft licenses forbid extraction of files and their incorporation into other products, whether sold or given away. MS-DOS 6 CD releases don't legally exist. MS-DOS is not "abandonware".

And your goal of it being loaded in A: after using a bootable CD ain't gonna happen...Quote from: patio on April 09, 2018, 01:11:58 PM

And your goal of it being loaded in A: after using a bootable CD ain't gonna happen...
I believe that if you create a bootable CD using 'floppy emulation' you would get an A: drive with the actual CD ISO files being on whatever letter MSCDEX takes. HOWEVER a LEGAL bootable FreeDOS CD I have found, http://pingtool.org/downloads/fd11src_live.iso boots into the CD part, Drive E:, on the system I tried it with, but you can go to an emulated floppy by typing A: and hitting ENTER.







According to the El Torito specification, a 32-bit CPU PC BIOS will search for boot code on an ISO 9660 CD-ROM. The standard allows for booting in two different modes. EITHER in hard disk emulation when the boot information can be accessed directly from the CD MEDIA, or in floppy emulation mode where the boot information is stored in an image file of a floppy disk, which is loaded from the CD and then behaves as a virtual floppy disk. This is useful for computers built before about 1999, which were designed to boot only from floppy drive.Thanx for that info Salmon...I'm not going to sell, trade giveaway. I just to show people the old Dos and what it look like. I didn't know I was going to cause a problem beside I own all the Software in question. I just others. I'm 70 years old. Everyone have a good day.For what it is worth...
Yes, somebody did do a boot up CD of DOS 6.22 and if you use it without a linseed you violate the Microsoft copyright.

But FreeDOS is free. And you can use to make a bootable USB device.
See the Rufus documentation.

Or see this link:
How to use Rufus to create a bootable USB drive to install (almost) any OS
You will note that Rufus can use FreeDOS to make a USB stick bootable.
Which one will work with CD and install on a Hard Drive? I do not use Windows just Linux.

Quote
CDROMCDROM “standard” installer

CDROMCDROM “legacy” installer

floppyBoot floppy (see notes below)

USB driveUSB “Full” installer

USB driveUSB “Lite” installer
You don't have Rufus for Linux. Rufus is a windows program.
See this:
https://alternativeto.net/software/rufus/?platform=linux
Quote
UNetbootin

UNetbootin (Universal Netboot Installer) is a cross-platform utility that can create Live USB systems and can load a variety of system utilities or install various Linux.
...

Etcher

Etcher is a free and open-source image burner with support for Windows, OS X and GNU/Linux. It makes USB and SD card image burning as simple and fast as possible. ...
Then thee is YUMI, which deserves special mention.
YUMI – Multiboot USB Creator
Quote
IMPORTANT NOTES: Your USB drive must be Fat16/Fat32/NTFS formatted, otherwise Syslinux will fail and your drive will NOT Boot. NTFS may not work with every DISTRIBUTION but is required for storing files over 4GB. YUMI UEFI must use Fat32 format.
YUMI can be used to format your select USB drive, but be aware that all partitions on the selected drive will also be deleted. Ensure that you have made a BACKUP of any information you want to keep before using YUMI on any drive.
That warning may also apply to other tools that make USB bookable devices. Yes, it is a multi boot thing, but it has to format the whole drive as one.

I don't believe YUMI writes to CD. NI nver tried. .
5654.

Solve : How do I unpack the old DOS .IMG files ??

Answer»

I have a whole bunch of games, they were in .IMG FORMAT, each file size is around 1.4MB, I assume they are the old Floppy image file ?

How do you unpack them ? I have tried dcf5, winimge, none WORKED. I remember I used to be able to unpack them all using some kind dos command (or may be 3rd party) back in 1994, 1995, but it's been too long.

All help appreciated. http://www.chrysocome.net/rawwriteYeah I tried that, it does'nt work, It won't recongize the file.Are the files on the original floppy disks? If so, the media tends to degrade over time and may be unuseable.I remember there used to be some kind dos command to be able to unpack those IMG files. No windows program was needed. I am sure I can still find it somewhere on the INTERNET, but I just can't remember the name of that command.The computer you are attempting to unpack them on is using what version of Windows?
There is no DOS since Windows 2000.I think those .IMG are not the normal Floppy IMG files, There's some kind of tool that I found on another 1996 CD ROM, it's called UNDISK, apperently it's designed to open those .IMG and .DDI files.


actuallly HD-Copy will do, but that requires a floppy drive which i don't have. sucky.Yay, I used Undisk successfully unpacked all of the .IMG files for 3Ds, some old games and other goodies. This is so AWESOME !!!What Dos program can extract an xxx.img file? I only use Linux.You should start a new Topic so it recieves proper attention...

5655.

Solve : My startup files.?

Answer»

I am a Linux user and I am a lot older now so I wanted to GO back to the olds so I went to the basement and got my MS-Dos 6.22 stuff. I have INSTALL it to a 256mb USB here is Autoexec.bat and Config.sys files. I like to KNOW if I need to change anything or not.

Here my Autoexec.bat
Quote

@echo off
PATH C:\;C:\DOS;C:\NC;C:\WORKS;C:\QB45
LH C:\DOS\SMARTDRV.EXE
LH C:\DOS\MSCDEX.EXE /S /V /D:TSSTcorp /L:J
rem C:\DOS\DOSKEY
LH C:\DOS\MOUSE\MOUSE.COM /Y
SET MOUSE=C:
PROMPT $P$G
Here my Config.sys
Quote
DEVICEHIGH=C:\DOS\HIMEM.SYS /TESTMEM:OFF
DEVICEHIGH=C:\DOS\EMM386 NOEMS
DEVICEHIGH=C:\DOS\SMARTDRV.EXE /DOUBLE_BUFFER
DEVICEHIGH=C:\DOS\CD\CD1.SYS /D:TSSTcorp /L:J
DEVICEHIGH=C:\DOS\USB\USBASPI2.SYS /V
DEVICEHIGH=C:\DOS\USB\DI1000DD.SYS
DOS=HIGH,UMB
FILES=30
BUFFERS=20
STACKS=9,256
LASTDRIVE=Z
Can anyone help me?Here what I came up with.

Autoexec.bat
Quote
@ECHO OFF
LH C:\DOS\SMARTDRV.EXE 2048 128
LH C:\DOS\MSCDEX.EXE /D:MSCD001 /L:D
LH C:\MOUSE\MOUSE.COM /Y
PATH C:\;C:\DOS;C:\NC;C:\WORKS;C:\QB
PROMPT $p$g
SET TEMP=C:\TEMP\
rem SET SOUND=C:\SB16
rem SET BLASTER=A220 I5 D1 H5 P330 T6
rem SET MIDI=SYNTH:1 MAP:G
rem LH C:\SB16\DIAGNOSE /S
rem LH C:\SB16\SB16SET /P
Config.sys
Quote
DEVICE=C:\DOS\HIMEM.SYS /TESTMEM:OFF
rem DEVICE=C:\DOS\EMM386.EXE HIGHSCAN
rem DEVICE?=C:\DOS\EMM386.EXE NOEMS
DEVICE=C:\DOS\EMM386.EXE AUTO
DOS=HIGH,UMB
FILES=30
BUFFERS=20
LASTDRIVE=Z
DEVICEHIGH=C:\DOS\SETVER.EXE
rem DEVICEHIGH=C:\DOS\DISPLAY.SYS CON=(EGA,,2)
DEVICEHIGH=C:\DRIVER\OAKCDROM.SYS /D:MSCD001
But it won't load in to high memory. What do I need to do?

5656.

Solve : backup batch file to recognize day names?

Answer» QUOTE from: RonC on April 28, 2018, 10:19:37 AM
Sorry people, I may have screwed up and my celebration was premature. I tried the coding you suggested and it didn't work. Here is the code for my bat file:
@echo off
cd\
cd\Users\RONALD\Desktop
if /i "%dayname%"=="Monday" copy current*.* f:\monday /y
if /i "%dayname%"=="Tuesday" copy current*.* f:\tuesday /y
if /i "%dayname%"=="Wednesday" copy current*.* f:\wednesday /y
if /i"%dayname%"=="Thursday" copy current*.* f:\thursday /y
if /i "%dayname% =="Friday" copy current*.* f:\friday /y
if /i "%dayname% =="saturday" copy current.* f:\saturday /y

When I RUN the bat file and then OPEN the directory f:\saturday it is empty. Am I not properly identifying a variable? I can't figure it out.

Thanks,

RonC
This code should have GIVEN you an error. You are missing a double quote for the comparison on Friday and Saturday.
5657.

Solve : Need help with a simple batch script?

Answer»

Quote from: patio on March 31, 2018, 02:04:26 PM

It souunds to me that the work STAFF are giving him impossible tasks...this is for work as per the 1st post.
Why they would do this i have no clue...
Let me guess.
A Government Agency? Thanks everyone for trying to help me solve this problem. The data was spit out of an OLDER version of measuring automated tool (CMM) in the form of picture and text PDF file. Since then they are MAKING the data available in excel which is manageable. My task is to extract numeric data from these old files - from the picture part of the pdf. The above strategy helps me do that manually through the sequence of conversions. I am looking for a way to automate the steps mentioned above.

Hope this helps.PDF's can be converted into Excel forms...

Or CSV...though i don't know if CSV's would be easier...
I have the standard Acrobat and I can turn a fully pictured pdf into an ugly excel file. But since all these CMM pdf files were generated the same way, I can always go to the same row 35 and column 12 and extract the needed data from them.

Hope this helps.

I am sorry hasn't replied lately, got into another fire fighting project. But I am back.

Appreciate any help and guidance.This is not an answer.
This is a word of caution.

There is a very string misconception with data generated by a computer.
Many layman, even professionals, bveli9ve data from computer is perfect.
Of course, that is not true. There is an old saying:
"Garbage in, Garbage out."
Automatic conversion of numerical from ONE format to another can lead to very harmful errors. Whit text, we humans often spot nonsense.That is a safegaurd that prevents use from publishing garbage.

We numerical data we humans do not know if the data is correct or not. When a report or a graphic is the result of Excel numerical data, people tend to believe it is flawless.

There have been some very bad financial disasters from bad data in spreadsheets.
https://www.telegraph.co.uk/finance/newsbysector/banksandfinance/11518242/Stupid-errors-in-spreadsheets-could-lead-to-Britains-next-corporate-disaster.html
Quote
Almost one in five large businesses have suffered financial losses as a result of errors in spreadsheets, ACCORDING to F1F9, which provides financial modelling and business forecasting to blue chips firms. It warns of looming financial disasters as 71pc of large British business always use spreadsheets for key financial decisions.
and...
https://www.nytimes.com/2013/04/19/opinion/krugman-the-excel-depression.html

Some has said that anybody who works with spreadsheets needs to be carefully vested as to sanity and soundness of mind.

Just a warning.



Will it help if you can convert the PDF to TXT file on the command line? If so, you can use Ghostscript to do this

https://www.ghostscript.com/download/

For example to create an output file pdf-output.txt from input file pdf-sample.pdf

Code: [Select]gswin64c -sDEVICE=txtwrite -o pdf-output.txt pdf-sample.pdf
5658.

Solve : Big Plea. Can anyone help on finishing off a script as completely confused ....?

Answer»

Hi

Ive sort of got my head round what I need to do but need one or two minor adjustments made as I dont know where they go as im totally confused with .msdos unless it written out for me.

I have the following .MSDOS and .VBS script that creates a folder & zips it

What I need to do in addition is the following.

1) When it puts it into a folder I need it to ask me to input a password . When password input I then need it to move onto the .DOS command of zipping

2) What I also need is instead of it just CREATING a 7Z file with the name of zipped.7z I need it to be the same name as what the folder was called originally.
I was advised of some code like this but aint got a clue on what it is or where it to go in script.

Code: Select all

@echo off
echo(The first command line argument is "%~1".

Code: Select all

Z:\>example.bat "argA" "argB"
The first command line argument is "argA".

CAN I MAKE ONE BIG BIG PLEA AND CAN YOU POSSIBLY AMEND MY SCRIPT BELOW AND JUST REPOST FOR ME PLEASE PLEASE


ORIGINAL SCRIPTS BELOW


Option Explicit

Const strDLFolder = "C:\Downloads"
Dim objFSO, objWShell, objDLFolder, strNewFolder, objFile

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWShell = CreateObject("WScript.Shell")

If Not objFSO.FolderExists(strDLFolder) Then objFSO.CreateFolder(strDLFolder)
objWShell.CurrentDirectory = strDLFolder
Set objDLFolder = objFSO.GetFolder(strDLFolder)
If objDLFolder.FILES.Count = 0 Then WScript.Quit

Do
Err.Clear
strNewFolder = InputBox("Folder Name", vbLf & "Enter the name of the folder to be created:")
If strNewFolder = False Then WScript.Quit
On Error Resume Next
objFSO.CreateFolder strNewFolder
Loop While Err.Number <> 0 Or Not objFSO.FolderExists(strNewFolder)

On Error Goto 0
For Each objFile In objDLFolder.Files
objFSO.MoveFile objFile.Name, strNewFolder & "\"
Next

objWShell.Popup "All files moved.", 0, "Done", vbInformation Or vbSystemModal Or &h00040000&

dim dotbat
set dotbat=createobject("wscript.shell")
dotbat.Run "C:\Users\icc.cctv\Documents\DONOTDELETE1.bat", 1, True
set dotbat=Nothing

@echo off&PUSHD "%PROGRAMFILES%\7-zip"&cls
echo MAKE SURE YOU HAVE ENTERED
echo STATEMENT INTO FOLDER BEFORE
echo CONTINUING^^!&echo.
echo [1] I'VE DONE THAT
echo [2] I'VE FORGOTTEN THAT
choice /c 12 /n>nul
if '%errorlevel%'=='2' (
cls&echo ENTER THE STATEMENT INTO FOLDER,
echo THIS WINDOW WILL CLOSE IN 5 SEC.
) else (
cls
7z a -t7z "C:\Downloads\zipped.7z" "C:\Downloads"
echo.&echo ALL FILES MOVED^^!
)
timeout 5 /NOBREAK >nul&exit/b


big big THANKS in advance



All you did was re-word your original request which was locked...so i'm lockin this one too.

5659.

Solve : Keep getting Variable is undefined.bat error anyone got any ideas why??

Answer»

Hi

I have a .VBS SCRIPT and a .bat file that im trying to run together.

Ive got this script that suppoused to runs the VBS script and then open the .BAT file.

I keep getting the ERROR variable is undefined .bat error come up when trying to run it. Can anyone help.

Thanks

Option Explicit
Const strDLFolder = "C:\Downloads"
Dim objFSO, objWShell, objDLFolder, strNewFolder, objFile
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWShell = CreateObject("WScript.Shell")

If Not objFSO.FolderExists(strDLFolder) Then objFSO.CreateFolder(strDLFolder)
objWShell.CurrentDirectory = strDLFolder
Set objDLFolder = objFSO.GetFolder(strDLFolder)
If objDLFolder.Files.Count = 0 Then WScript.Quit
Do
Err.Clear
strNewFolder = InputBox("Folder Name", vbLf & "Enter the name of the folder to be created:")
If strNewFolder = False Then WScript.Quit
On Error Resume Next
objFSO.CreateFolder strNewFolder
Loop While Err.Number <> 0 Or Not objFSO.FolderExists(strNewFolder)
On Error Goto 0
For Each objFile In objDLFolder.Files
objFSO.MoveFile objFile.Name, strNewFolder & "\"
Next
objWShell.Popup "All files moved.", 0, "DONE", vbInformation Or vbSystemModal Or &h00040000&
dim dotbat
set dotbat=createobject("wscript.shell")
dotbat.Run "C:\Desktop\testersnew.bat", 1, True
set dotbat=Nothing

and ive also tried the command below too in the middle.

dotbat.Run "cmd /C C:\Desktop\testersnew.bat", 1, True
I'm locking this thread and closing your tweacle ACCOUNT. You ALREADY have an active account on this site with the username shreked. One account per customer Mr. Masters.

5660.

Solve : Extract Image?

Answer»

I have some Dos program's I converted back in the 90's but I can't remember what I used and I want to use again.

What Dos program can extract an xxx.img file? I only use Linux now.

Can anyone help me? It's not a widely used format...but i READ that Gimp can do it as they are image files...I just found this and I will give it a try. http://www.winimage.com/extract.htm The maker of Winimage.Quote from: Jmdlcar on April 12, 2018, 05:36:58 PM

I just found this and I will give it a try. http://www.winimage.com/extract.htm The maker of Winimage.
You said in your first post that you wanted to do it on Linux. If you Google SEARCHED at all, you should be ABLE to do it with the good ole MOUNT command.Gimp runs on many Linux distros...Quote from: patio on April 16, 2018, 04:17:53 PM
Gimp runs on many Linux distros...
Seems odd that Gimp would OPEN a disk image file.Disc image file.....ahhh. I read too QUICKLY...Thanx.
5661.

Solve : Can I set up a auto DOS / BATCH FILE?

Answer»

Hi

I have a 7 zip file that I need to unzip but not save it to personal computers but a folder on the server.

Im trying to make is easy so just a click on a icon and Im THINKING of a script or command that someone clicks on and asks what subfolder they want to open within the folder and then asks for password thats on the subfolder and unzips as a complete folder to a specific location.

The script or command will always be in the folder so people can just click on it to open files. If 7 zip is difficult I can use the zip function in windows .

Im very rusty on .DOS so any reply in easy english would help.

Folder is C:\Downloads and there will be zipped sub folders within of which I need to unzip etc. They need to unzip to R:\DOWNLOADS

Has anyone any ideas or other suggestions?Supplying a solution to this... the solution can be used to send an e-mail to someone with a zipped file that had hidden malicious intent then of which the zipped contents decompressed to infect or attack etc.

*If you have access to said "server" you have a BETTER means of implementing this "directly" either at the system or through remote system management options that you should have available to you as the system admin.

The danger with this one is that:

Quote

Im trying to make is easy so just a click on a icon and Im thinking of a script or command that someone clicks on and asks what subfolder they want to open within the folder and then asks for password thats on the subfolder and unzips as a complete folder to a specific location.

Can be automated in the batch supplied to you where INSTEAD of a user given a choice of path and password entry, these fields could be set to static values so that once they click on the "icon" it runs and unzips automatically password protected file and does whatever else you want.

Sorry about my caution in assisting with this, but as a system administrator yourself of this server, you should see how this could be easily used for wrong intent, and as a system admin you should have access to this said server so that this method of "others" running this on servers is not necessary.

SOUNDS NEFARIOUS.....Topic Closed.

5662.

Solve : Re: phone dialer.?

Answer»

Quote

== Could the Phone dialing and pre recorded call through computer.

Any suggestion/Links

Thanks N Regards,
Jay



Not sure what you are asking for. Can you explain?


If by chance you are looking for a way to DIAL out, using a dos program, then you might LIKE to CHECK out:

http://en.wikipedia.org/wiki/Telix
and
http://www.telix.com/delta/deltacom/tfd/

5663.

Solve : Help For 2nd time!?

Answer»

echo echo %%ENG%% = %%ENGX%% &GT;> falures.txt >> glosor.bat
i WANT to be able to WRITE:echo echo %%ENG%% = %%ENGX%% >> falures.txt in glosor.batcan u explain more its CONFUSING

5664.

Solve : Help with bat2exe?

Answer»

Will someone please help me with bat2exe, i have no clue what to do with it.I ASSUME that you want to produce compiled versions of bat files

TRY bat2exe /? this would normally give a clue as to the usage

it is probably something like
bat2exe MyBatchName.bat

which will produce MyBatchName.exe

note that the dos commands it recognises will only be up to version 5 or 6, not the more recent enhancements

GrahamYou have to put bat2exe into the system32 folder.

There are better programs to convert .bat to exe's like...
-->http://www.brothersoft.com/file_disk_management/miscellaneous/bat_to_exe_converter_download_50301.html<--
Yes i know its in German but all you have to do is put the path of the batch file in the top bar and tick the right tickbox and click the right button to convert (i figured it out)Quote


You [highlight]have to [/highlight]put bat2exe into the system32 folder.


Why?

Because if you don't and you leave bat2exe on the desktop, you have to type C:\docume~1\%username%\desktop\bat2exe.com batchfile.bat

If you put it in system32 or where cmd.exe is, all you have to type is bat2exe.com batchfile.bat

The reason why I dont USE bat2exe is because it doesn't support many commands. it keeps saying 'syntax ERROR' or 'unrecognized command' and stuff like that.Quote

Because if you don't [highlight]and[/highlight] you leave bat2exe on the desktop, you have to type C:\docume~1\%username%\desktop\bat2exe.com batchfile.bat


The first time, you made it a blanket STATEMENT. Now it is conditional.
Just wanted to clear that up.

The statement, "You have to put bat2exe into the system32 folder.", is not good advice because it is not correct.


Btw, "you have to type C:\docume~1\%username%\desktop\bat2exe.com batchfile.bat" is not correct either.
Just navigate to that directory first.
Quote
You have to put bat2exe into the system32 folder.
another way is to set the PATH env variable to where bat2exe is installed. don't really have to put it in system32Quote
Because if you don't and you leave bat2exe on the desktop, you have to type C:\docume~1\%username%\desktop\bat2exe.com batchfile.bat
Can't you just drag the folder into the cmd.exe window, and the folder path will appear?
yea fine..that works too....Basically to use bat2exe, put it on your desktop, open command prompt and type %userprofile%\desktop\bat2exe.com batchfile.bat and press enter and it will work.Quote
Basically to use bat2exe, put it on your desktop, open command prompt and type %userprofile%\desktop\bat2exe.com batchfile.bat and press enter and it will work.


As time goes by, and you experiment with various programs, you'll find that your desktop gets cluttered.

I usually keep a directory just for playing around. Something like
c:\testing
Something like bat2exe would go in there, then when I open a 'dos' window it is quick and easy to cd to that directory.
I'd do my testing from that directory, and not have to fool around with long command lines and environment variables.
Much easier.

When I find a utility program that I like and wish to keep handy,
only then do I put it in my path.
I do not think it is wise to have a lot of directories in the path, let alone the operating system limits on the path length.
Having too many directories in the path just seems sort of sloppy to me, and eventually will yield some surprise results.

Therefore, I make one directory for utility programs, and put it in the path. You can search here on CH for path , and find good reading on it.
Something like bat2exe might find its way in there, assuming the program will behave properly when executed that way.
For example, I keep pkzip.exe, pkunzip.exe, some other archivers, list.com, and fdate.exe in my "utils" directory, which is in the path.
This kind of organization has served me well. It works, and files are not all over everywhere.

I hope this helps.


5665.

Solve : TIME?

Answer»

so i was wondering is there a way to load TIME like infinite times like :

@echo off
:1
color f1
cls
echo %time%
goto:1

but if i want to run it wif other commands it wont WORK CAUSE it wil just keep going to :1 thats the problem i want it both to run the time and run the program AT THE SAME TIMEEEEE HELPPPI don't think thats possible.....because it will keep looping to the beginning and even if you can type SOMETHING, you wont be able to because its too FAST.

5666.

Solve : Need help in dos command?

Answer» SORRY for my weak English

how can I make a dos script to find the windows directory name from boot.ini ( i THINK find command)
and set it as a variable ? (i think set command )
no HELP Quote from: Help Me on April 12, 2008, 04:28:21 PM
how can I make a dos script to find the windows directory name from boot.ini

Why do you want to do that? In WIN2K it's WINNT - in Win XP it's WINDOWS and the path/foldername is already Set in the environment variable %SystemRoot% - AFAIK boot.ini does not exist in Vista.

what does your boot.ini look like now
5667.

Solve : how come this wont work??

Answer»

This wont work:

ipconfig /all &GT; C:\DOCUMENTS and Settings\Dakota\Desktop\dump\dump\DAKOTA-LAPTOP\ipconfig.txt

But this will:

ipconfig /all > C:\dump\ipconfig.txt


Thanks for the help.because you have a space in the PATH. Use quotes to escape the spaces.Quote from: ghostdog74 on April 13, 2008, 01:54:43 AM

Use quotes to escape the spaces.

like this

ipconfig /all > "C:\Documents and Settings\Dakota\Desktop\dump\dump\DAKOTA-LAPTOP\ipconfig.txt"
5668.

Solve : Patch file for network registry?

Answer»

Dear all ,
Could you help me to make batch file to change some keys for network computers:
All PCs joined Domain and i have an account to login into any PC after that I can access to any PC via Regedit than connect to remote registry but i want to make batch file to do that in one transaction and i want to make the computer name is a variable:
-Path and values that I want to change is the
path: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
Name Type Data
AutoAdminLogon REG_SZ 1
DefaultUserName REG_SZ EMO
Defaultpassword REG_SZ 123456

Note: all values just are Example.
-If any one can help me please don't hesitate to do that and if anyone can make such as this batch file and send it to me also please don't be late to help thanks all for your listening to meCan you test this on a test machine? You will need to run it as admin.

Code: [Select]@echo off
set machine=192.168.0.100
set "key=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
reg \\%machine%\"%key%" /v AutoAdminLogon /t REG_SZ /d 1 /f
reg \\%machine%\"%key%" /v DefaultUserName /t REG_SZ /d EMO /f
reg \\%machine%\"%key%" /v Defaultpassword /t REG_SZ /d 123456 /f
@echo off
set machine=192.168.0.100
set "key=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
reg \\%machine%\"%key%" /v AutoAdminLogon /t REG_SZ /d 1 /f
reg \\%machine%\"%key%" /v DefaultUserName /t REG_SZ /d EMO /f
reg \\%machine%\"%key%" /v Defaultpassword /t REG_SZ /d 123456 /f


Dear foxidrive

Firstly: thanks for your appreciation and I will use your batch.
Secondly: And I'm sorry for my MISS understanding for these parameters could you please explain these parameters to me ( /v , /t , /d and /f ) and why you don't use REG ADD instead REG only as i saw before and if tried to use this batch it's will overwrite the keys already EXIST or what?
- Can I use a variable as i want without editing in my batch every time
- Could you explain this to me by details every steps So that I can later develop myself in this batch language.
I'm so sorry again for your Inconvenience i'm just beginnerWow...Abo-Zead,
The blue font color is really starting to get annoying. In my opinion you should only use color to draw attention to a specific phrase or sentence that is important. There is no need to make all of your post a DIFFERENT color. Please keep it to the default black.Quote from: Squashman on August 19, 2015, 02:05:24 PM

Abo-Zead,
The blue font color is really starting to get annoying. In my opinion you should only use color to draw attention to a specific phrase or sentence that is important. There is no need to make all of your post a different color. Please keep it to the default black.


Dear Squashman,

I'm so sorry for your annoyance I did not mean that and I will take your advice in the next times.
And If any one can help me please don't hesitate to explain the previous Post.Yes, it does need 'add' in each reg command - and will overwrite existing INFO, if I understood the help correctly.

Code: [Select]@echo off
set machine=192.168.0.100
set "key=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
reg add \\%machine%\"%key%" /v AutoAdminLogon /t REG_SZ /d 1 /f
reg add \\%machine%\"%key%" /v DefaultUserName /t REG_SZ /d EMO /f
reg add \\%machine%\"%key%" /v Defaultpassword /t REG_SZ /d 123456 /f


You will have to test it on a machine to confirm that it works before it can be modified, and also explain how you are getting the IP address of the machines - so the appropriate modifications can be made.

Quote from: foxidrive on August 20, 2015, 04:04:23 AM
Yes, it does need 'add' in each reg command - and will overwrite existing info, if I understood the help correctly.

Code: [Select]@echo off
set machine=192.168.0.100
set "key=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
reg add \\%machine%\"%key%" /v AutoAdminLogon /t REG_SZ /d 1 /f
reg add \\%machine%\"%key%" /v DefaultUserName /t REG_SZ /d EMO /f
reg add \\%machine%\"%key%" /v Defaultpassword /t REG_SZ /d 123456 /f


You will have to test it on a machine to confirm that it works before it can be modified, and also explain how you are getting the IP address of the machines - so the appropriate modifications can be made.



Ok, foxidrive

I'll test this may be today or tomorrow and feedback you ASAP .
but i think we can using the Hostname instead the IP
and can use set "k=" , SET /P "K= and IF /i %K%== conditions to make the IP or Hostname is variable .
and i can't understand what the meaning of /v , /t , /d and /f can you explain
We appreciate you for your effort to help me
Quote from: Abo-Zead on August 20, 2015, 07:41:05 AM
but i think we can using the Hostname instead the IP
and can use set "k=" , SET /P "K= and IF /i %K%== conditions to make the IP or Hostname is variable .

Hostname should work - but are you typing in each hostname from the keyboard?

Quote
and i can't understand what the meaning of /v , /t , /d and /f can you explain

In a cmd prompt type reg add /? and read the help and examples.
If there is something you can't figure out then discuss which part you don't understand.
Quote from: foxidrive on August 20, 2015, 09:15:41 AM
Hostname should work - but are you typing in each hostname from the keyboard?

In a cmd prompt type reg add /? and read the help and examples.
If there is something you can't figure out then discuss which part you don't understand.


Hi foxidrive,

I have modified the Batch file as my requirements and when tested it gives me an error" invalid key name" and here is the final batch attached if you want to look and edit and the result.


[attachment deleted by admin to conserve space]It requires the double quoting around the entire first term, not just %key% where I had put it.

Test this on a non-critical machine.

Code: [Select]@echo off
set machine=cai3c332
set "key=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
reg add "\\%machine%\%key%" /v AltDefaultDomainName /t REG_SZ /d CAI /f
reg add "\\%machine%\%key%" /v AltDefaultUserName /t REG_SZ /d muslogon /f
reg add "\\%machine%\%key%" /v AutoAdminLogon /t REG_SZ /d 1 /f
reg add "\\%machine%\%key%" /v DefaultDomainName /t REG_SZ /d CAI /f
reg add "\\%machine%\%key%" /v DefaultPassword /t REG_SZ /d esumiac /f
reg add "\\%machine%\%key%" /v DefaultUserName /t REG_SZ /d muslogon /f
reg add "\\%machine%\%key%" /v ForceAutoLogon /t REG_SZ /d 1 /f
pauseQuote from: foxidrive on August 21, 2015, 04:10:38 PM
It requires the double quoting around the entire first term, not just %key% where I had put it.

Test this on a non-critical machine.

Code: [Select]@echo off
set machine=cai3c332
set "key=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
reg add "\\%machine%\%key%" /v AltDefaultDomainName /t REG_SZ /d CAI /f
reg add "\\%machine%\%key%" /v AltDefaultUserName /t REG_SZ /d muslogon /f
reg add "\\%machine%\%key%" /v AutoAdminLogon /t REG_SZ /d 1 /f
reg add "\\%machine%\%key%" /v DefaultDomainName /t REG_SZ /d CAI /f
reg add "\\%machine%\%key%" /v DefaultPassword /t REG_SZ /d esumiac /f
reg add "\\%machine%\%key%" /v DefaultUserName /t REG_SZ /d muslogon /f
reg add "\\%machine%\%key%" /v ForceAutoLogon /t REG_SZ /d 1 /f
pause

Yes, MR foxidrive it's WORKING now
many many thanks for your great effort with me.


thank
5669.

Solve : Batch File/GP installation issue?

Answer»

Hello,

I have a BATCH file attached to a group policy that is supposed to install an .msi. For some reason, when I apply the GP to the OU I want and RESTART said computers, the program will only install on some (not all) of the computers in the OU. The MSI in QUESTION is located on a network share that is accessible by all computers. I created a log EXPORT for the GP, compared it to the installs that work and I noticed two things:

1) Failed to grab execution mutex. System error 258
2) MainEngineThread is returning 1618

It looks like the 1618 is due to an application already running. How can I fix my group policy (or batch file) to resolve this issue? I'm just starting to work with batch files and any help WOULD be greatly appreciated.

Thanks!This URL has information which may be applicable regarding Failed to grab execution mutex. System error 258

Quote

That is the problem, yes, you cannot run recursive MSI installs, and that's enforced using a mutex, so the log shows that the second install cannot run because there is already one in progress.
This is the kind of thing that the bootstrap manifest generator could do, AFAIK, and that would customise the setup.exe launcher to include the PIAs.
Thanks. Any idea how to modify a batch file so multiple computers don't try and run recursive msi's? It'd be good to know if the computers could see if the installer is in use, wait till it's done and then start the install so it doesn't fail with the mutex error?It may be that the batch script is installing multiple things and not waiting between different installs.

Using the /wait switch with the start command may help.


start "" /w "file1.msi" /switches
start "" /w "file2.msi" /switches
start "" /w "file3.msi" /switchesThere's brand loyalty for you!
5670.

Solve : Application/ Script for capturing continuous Trace route with Timestamp?

Answer»

Hello,
Good Morning..!!!

Please help suggesting an application or help in developing a script/ batch file through which i can capture continuous trace route of an IP address with time stamp.

Regards,
GCMaybe show us a small example of what you want your output too look like.My thoughts on this is that your time stamp with not be exact to that of the TRACEROUTE routine for each hop, so if your looking for extreme precision of lesser than say 10 seconds of time, it can be troublesome without using a different program than traceroute that has this feature built into it or programming your own which is usually not in the means of those looking for assistance with doing this.

The issue for actual time stamp of each hop is that you will be running Traceroute function which when running takes the single threaded priority of the command SHELL, and each hop takes time. You could capture a time stamp prior to Traceroute and one at the end of the Traceroute routine and know that between this time frame this is what was measured and the route taken.

Also it depends on how many hops you want, to what depth of routing you require. As well as are you only tracerouting a specific destination or a bunch of them?

CODE: [Select]@echo. Traceroute Sample Started %date% at %time%>>Traceroute.log
tracert www.google.com>>Traceroute.log
@echo. Traceroute Sample Ended %date% at %time%>>Traceroute.log
This would give you start and stop time of the traceroute and all contents of the traceroute, but you wouldn't see any info to display when this is happening as for the information is redirected to WRITE to Traceroute.log Just need to replace www.google.com with whatever your tracerouting.

5671.

Solve : Batch file help - reformatting text?

Answer»

Hey all,
I'm trying to do something very specific here... I have a file, it's anywhere from 1 to 15 lines, and each line only contains one word (a computer name). This "list" needs to be fed back into another text file, newlist.txt, in the format below:

word1, word2, word3, word4, etc...

So basically, I want to make it comma delimited. I've tried various THINGS with FOR and IF, but they're just not working; best I got was this:

word1
,
word2
,
word3
,
etc...

Any help WOULD be appreciated, but if it could be limited to dos COMMANDS, that would be preferable. I'm not sure I'll be in an ENVIRONMENT where VB scripts will work, but if that's my *only* way, so be it.

Thanks!You didn't MENTION an OS but this has been known to work on some of them:

Code: [Select]echo off
setlocal enabledelayedexpansion
for /f %%v in (myFile.txt) do (
call set oneline=!oneline!,%%v
)
set oneline=!oneline:~1!
echo %oneline%

Be sure to change myFile.txt to something more usable.



this works on dos/xp
Code: [Select]@echo off
set text=
for /f %%a in (myFile.txt) do call :settext %%a
goto end
:settext
if "%text%"=="" (
set text=%1
) else (
set text=%text%, %1
)
goto :eof
:end
echo %text% >newlist.txt
Quote from: Ceeler on March 28, 2008, 02:19:21 PM


I'm not sure I'll be in an environment where VB scripts will work, but if that's my *only* way, so be it.


unless you are working with prehistoric machines with prehistoric OS, otherwise, yes vbscript can be used, from Win95/98 onwards.
Here's one
Code: [Select]Set objFS = CreateObject("Scripting.FileSystemObject")
strFile = "c:\test\file.txt"
s=""
Set objFile = objFS.OpenTextFile(strFile)
Do Until objFile.AtEndOfLine
s=objFile.ReadLine & "," & s
Loop
WScript.Echo s
save as script.vbs and on command line(batch)
Code: [Select]c:\test> cscript /nologo script.vbs
5672.

Solve : download?

Answer»

I PURCHASED 2 cd discs but when i try to download them, the message
C:\Windows\System\Autoexe.NT
The system file is not suitable for running MS-DOS and Microft Windows appliations Perhaps you could tell us what the DISKS are?

How do you "download" a disk?
one disc is technical ASSISTANCE manual and the other one is a spare parts catalogue (alfa romeo)I think you MEAN "run" the disks, "download" means something different.

See here

http://support.microsoft.com/kb/324767
Thank you very much for the info WORKED 1st time
Many thanks

5673.

Solve : help iperf command?

Answer»

Hi,
I NEED to use iperf command and i want to send the results in a file.
I did that with this instruction:

iperf3.exe -c 127.0.0.1 > nomefile.

It's rigth,but i want to visualize the results while it works on the DOS windows. How can i do?

thankshttp://www.dostips.com/forum/viewtopic.php?p=32615Sorry,
I'm not very EXPERT, i have to write all dos instruction in a line because i will use it for my java application.
Can you HELP me writing a simple instruction to do that.

thanksYou are referring to what we CALL a TEE in the unix world. Windows does not have a native command to do do that. So no! There is no simple instruction to do what you want to do without using a 3rd party utility to do it.

5674.

Solve : Batch file problem, date and time don't show results.?

Answer»

Hello everybody.
I'm having problems with a file batch, in fact, I have two files, they are the following:

reloj.bat:
@echo off
date time pause

reloj.txt:

(It is just an "enter.")

Then I run reloj.bat from CMD and it jumps directly to the pause command and displays the message "Press any key to continue . . . "
To make clear some points: I've tried this batch program in windows 7 32 bits, windows 7 64 bits and windows xp 32 bits, but in all those operating systems it has just failed, and something else, they all were virtual machines.
Does anyone have any idea of how to succeed this problem? I really need it for this class guys.

Thanks for your help, see you!

Untested, but maybe it has to be % % for these.


reloj.bat:
@echo off
%date% %time% pause

reloj.txt:No, Dave, that won't do anything. Memowii -

1. What are you INTENDING to achieve?

2. What are the outputs of the date and time commands on your system?

To clarify, on my system the date command gives an output like this

c:\>date
The current date is: 03/09/2015
Enter the new date: (dd-mm-yy)

and the time command gives an output like this

c:\>time
The current time is: 18:02:29.90
Enter the new time:


What I am getting at is this:

What this line of code:
date &LT;reloj.txt | find "actual"
does is this:

Make the date command read its input from reloj.txt (which just contains a newline). This makes it behave the same as if you had run the date command and PRESSED Enter on the keyboard. The date command expects either:

A valid date in your local date format as shown in the prompt, i.e. the second line e.g. Enter the new date: (dd-mm-yy) (it changes the system date to whatever you entered)

Or

Enter (it changes nothing and exits.)

Next, both lines of the date command are passed to the find utility, with the search string "actual". The find utility will block any lines that do not contain "actual". If your date command output does not have the word "actual" in either line then nothing will be shown. Likewise for the time command.

I expect you want to show the first lines of the date and time commands. Those are the interesting ones. If you are in an English language locale you would probably do something like this

date <reloj.txt | find "current"
time <reloj.txt | find "current"

If you are not actually using the date and time commands in your real script (e.g. you are disguising what is happening in your script) and/or you have locale and language settings other than English, then you have been wasting quite a lot of our time.

By the way, you don't need to use a file with a newline in it to force an Enter into a command; you can use echo. with a pipe like so:

echo. | date







Are you by any chance using Spanish locale where actual means current e.g. hora actual?
First of all, I have to say Thank you for your great help and time.

Second, the output that I expected was the following:
The current date is: 03/09/2015
The current day is: 20:24:31.37
Press any key to continue...

Third, WELL, the real problem was with the O.S.'s language, as Salmon Trout explained it in his interesting answer.
My professor wrote this code in a windows 7 O.S. whose language is Spanish. And I use a virtual machine with windows 7 (32 bits) whose language is English, in fact, all my virtual machines are in English, you know, to practice the language.
So, when I saw the word "actual" in my professor's code, I actually thought about the English word "actual": existing in act, fact, or reality; real.
And when "actual" is translated into English it becomes "current", and it solves the problem, showing me the output that I've posted in this post.Code: [Select]echo. | DATE | find "current"
OR

Code: [Select]<nul set /P .=The Current Date is: &DATE /TWhat's wrong with:

Echo The current date is: %date%

Quote from: Salmon Trout on September 04, 2015, 10:17:07 AM

What's wrong with:

Echo The current date is: %date%
That would be way to simple!
5675.

Solve : login script?

Answer»

previously i use this script on SERVER 2003 to map drive through network for clients PC.

Dim wshNetwork
Set wshNetwork = CreateObject("Wscript.Network")
wshNetwork.MapNetworkDrive"x:","\\Server\Documents\Senior-Advisor"
wshNetwork.MapNetworkDrive"Z:","\\Server\Documents\Public"
WSCript.Quit

but now am chenge to windows server 2008 r2 but when i use the previous script on server r2 can not map on the clients pc. is their any OPTION to use this script or modified please help me thanks in advance . Did the name of the server change? We recently switched from 2003 server to 2012 server and we didn't have to make a single change to our drive mappings for our login script because we kept the server names the same.

You might CONSIDER putting in some spaces between the OBJECT reference and the drive letter just for readability.Why the Poll ? ?

5676.

Solve : Getting volume label name?

Answer»

Hello. Thanks for any help. I need some help in writing a batch dos command script that will check the name of the C: drive and if it does not match what I expect, will display a message. REASON is I have SEVERAL bootable harddrives in my system and when I boot up, I want to make sure I'm on the correct drive.

BTW, I'm running XP Home.

Thanks.Code: [Select]for /F "tokens=6" %%G in ('VOL C:') do set vol_label=%%GThanks. Worked like a charm. If you could help with one more thing, I'd appreciate it. I want to check to see if the label is a particular one and if not, then exit the routine. I've tried a few things but can;t get it to work. Something like:

(
if not %vol_label1% == "My_Label"
exit
)
:: Do something
exit

Got it to work. Thanks.Squashman's code will need a tweak if your label contains spaces.


Here's ANOTHER method to check a unique label and echo a message.

Code: [Select]vol c: |find "my label" >nul || echo This isn't your pr0n stash, try another drive!Quote from: foxidrive on September 09, 2015, 09:13:05 AM

Squashman's code will need a tweak if your label contains spaces.

Code: [Select]for /F "tokens=5*" %%G in ('VOL C:') do set vol_label=%%HAnother method that works well is to put a FILE in the root with a unique filename and then check if that file exists. You can easily create a very small file with the command "echo > My_Disk". Not necessarily any better than using the VOLUME but simply an alternative.Quote from: strollin on September 09, 2015, 09:33:07 AM
Another method that works well is to put a file in the root with a unique filename and then check if that file exists. You can easily create a very small file with the command "echo > My_Disk". Not necessarily any better than using the volume but simply an alternative.
Yes. Definitely not the best alternative considering the security settings Microsoft puts in by default on the root of the C: drive now.
Code: [Select]C:\>echo. >My_Disk
Access is denied.I should have mentioned that you just need to do that from an Admin command prompt.
5677.

Solve : Rename nearly 21k files according to XML File?

Answer»

Hi Everyone,

Just found this forums and have a problem that I hope someone can resolve for me.

I have a large collection of music which I have been using on a media centre for a while now, but its time to upgrade and update to a newer player, and thats the problem, the old player appears to have RIPPED CD's to the hard drive but named them funny and stored the correct name details and metadata in an XML, so when I now look at the new player I get file name such as AD1346.mp3 instead of the song name which with so many songs is impossible to go through manually.

XML File is like:-


13046

the 13046 is the file name but in reallity the file is called A0013046.mp3

I am looking for somesort of way of getting a rename program to look at this XML, update the filename and metadata to the correct format for a media player

Any Idea's would be greatly appreciated

Chris

Microsoft supplies an object which allows you to extract the information from an XML file. You will need to use VBScript.

Code: [Select]Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.async = False
xmlDoc.load("c:\temp\Songs.xml")

Set colNodes = xmlDoc.getElementsByTagName("Song")
For Each node In colNodes
Set objNamedNodeMap = node.attributes
artist = objNamedNodeMap.getNamedItem("Artist").text
title = objNamedNodeMap.getNamedItem("Title").text
srchArtist = objNamedNodeMap.getNamedItem("SearchArtist").text
srchTitle = objNamedNodeMap.getNamedItem("SearchTitle").text
style = objNamedNodeMap.getNamedItem("Styles").text

For Each child In xmlDoc.documentElement.childNodes
filename = xmlDoc.getElementsByTagName("Audio").item(0).text
Next

WScript.Echo "Artist-" & artist
WScript.Echo "Title-" & title
WScript.Echo "Srch Artist-" & srchArtist
WScript.Echo "Srch Ttirle-" & srchTitle
WScript.Echo "Style-" & style
WScript.Echo "Filename-" & "AD" & filename
Next

The snippet is simply a template. It is based on the information that was posted. It might need tweaking if the XML file has more nodes than posted. I put your song xml data into a file called songs.xml for testing purposes.

There is also a downloadable object named CDDBControl.dll (Google can find it) that can be used to extract the metadata from the music files. Assuming the metadata was updated, this could be used in a Vbscript not using the xml file.

Good luck.


Hi,

Sorry I think I have been missunderstood, the XML File already exists with this data, the problem is that the music files as they are do not include this info, ithey are named things like AD00001.wma, the progeam I have then looks at the XML file to get the artist data etc.

I am looking for a way to reverse this so need something to look at the XML file to get the information, then inject it into the appropriate music file, something like:-

It looks into the XML File and get this:-


13046

Then with this info it looks for music file called AD0013046.wma and renames to artist-song.wma and injects the info also into the file properties for it if this makes sence.

The details in the XML are as above for them music, is it was a small amount I would have done manually, but with 21k I was thinking there has to be a better way

Thanks.1. What is it you want help with, parsing the xml file, or "injecting" the metadata into the wma file? (do you mean tagging it?) Or both?

2. How was the xml file produced? By some program? What is its name?

3. Is each music file associated with 2 lines in the xml file thus:

[line 1]
[line 2] 13046


Hi,

I have the XML Data with all the names and music info layed out as


13046

There are currently 21k files named AD00001.wma up to just below 21k which as missing this info, what I am looking to do is take the information from this XML file and inject it into the music files.

I am looking to use a program called Media Maestro LSX which Can take info from Media Player and Itunes to create a home jukebox, but as it stands media player does not know what these music files are due to the data being held in seperate files, so I need a way to get this info back into the files.

ThanksQuote from: chrism on November 20, 2011, 05:01:33 AM

it looks for music file called AD0013046.wma

It was an .mp3 file before!

Hi,

Sorry yes, MP3 was a mistake, they are all .wma filesThis was difficult because no parent node was shown in the sample XML. So I MADE one up called Music.

There was also an error in the original script which has been corrected. Also the rename logic has been added. The script rename the AD files on disk using a combination of the artist and title name. The files are renamed on the disk. If you need to update the ID3 tag info let us know.

Sample Test Data:
Code: [Select]<?xml version="1.0" encoding="utf-8"?>
<Music>
<Song Artist="artist here " Title="thesongname here" SearchArtist="artist name" SearchTitle=" title" Styles="70s">
<Audio>13046</Audio>
</Song>
<Song Artist="Traffic" Title="The Low Spark Of High Heeled Boys" SearchArtist="Traffic" SearchTitle="The Low Spark Of High Heeled Boys" Styles="70s">
<Audio>66666</Audio>
</Song>
<Song Artist="Beatles" Title="Beatles VI" SearchArtist="Beatles" SearchTitle="Beatles VI" Styles="60s">
<Audio>45678</Audio>
</Song>
</Music>

The is the new script:
Code: [Select]Set xmlDoc = CreateObject("Microsoft.XMLDOM")
Set fso = CreateObject("Scripting.FileSystemObject")

xmlDoc.async = False
xmlDoc.load("c:\temp\Songs.xml")

Set colNodes = xmlDoc.getElementsByTagName("Music/Song")
For Each node In colNodes

Set colAttrib = node.attributes
artist = colAttrib.getNamedItem("Artist").text
title = colAttrib.getNamedItem("Title").text
srchArtist = colAttrib.getNamedItem("SearchArtist").text
srchTitle = colAttrib.getNamedItem("SearchTitle").text
style = colAttrib.getNamedItem("Styles").text

filename = "AD" & xmlDoc.getElementsByTagName("Audio").item(i).text & ".wma"

WScript.Echo "Artist-" & artist
WScript.Echo "Title-" & title
WScript.Echo "Srch Artist-" & srchArtist
WScript.Echo "Srch Title-" & srchTitle
WScript.Echo "Style-" & style
WScript.Echo "Filename-" & filename
WScript.Echo"--------------------------------------------"

Set f = fso.GetFile(filename)
f.Name = artist & "-" & title & ".wma"
i=i+1
Next

Save this into the same folder where the songs and XML file live. Save with a VBS extension and RUN as cscript scriptname.vbs There might be some excessive code in the script. It will not harm anything.

Recommend you test this out in a test directory before going live. Testing turned up no errors.


Please help
(1) i have one xml with lots many tags
(2) i have many audio files with random generated number as a name and that name is in XML file
(3) please tell me how can i rename those audio files with one of tag details present in xml file. i have to search that audio file as the name of the audio file is present in xml and under that section i will use one of the tag to rename it

example
-
-
Gambardella, Matthew
XML Developer's Guide
Computer
44.95
2000-10-01
An in-depth look at creating applications with XML.

-
Ralls, Kim
Midnight Rain
Fantasy
5.95
2000-12-16
A former architect battles corporate zombies, an evil sorceress, and her own childhood to become queen of the world.

-
Corets, Eva
Maeve Ascendant
Fantasy
5.95
2000-11-17
After the collapse of a nanotechnology society in England, the young survivors lay the foundation for a new society.

-
Corets, Eva
Oberon's Legacy
Fantasy
5.95
2001-03-10
In post-apocalypse England, the mysterious agent known only as Oberon helps to create a new life for the inhabitants of London. Sequel to Maeve Ascendant.

-
Corets, Eva
The Sundered Grail
Fantasy
5.95
2001-09-10
The two daughters of Maeve, half-sisters, battle one another for control of England. Sequel to Oberon's Legacy.

-
Randall, Cynthia
LOVER Birds
Romance
4.95
2000-09-02
When Carla meets Paul at an ornithology conference, tempers fly as feathers get ruffled.

-
Thurman, Paula
Splish Splash
Romance
4.95
2000-11-02
A deep sea diver finds true love twenty thousand leagues beneath the sea.

-
Knorr, Stefan
Creepy Crawlies
Horror
4.95
2000-12-06
An anthology of horror stories about roaches, centipedes, scorpions and other insects.

-
Kress, Peter
Paradox Lost
Science Fiction
6.95
2000-11-02
After an inadvertant trip through a Heisenberg Uncertainty Device, James Salway discovers the problems of being quantum.

-
O'Brien, Tim
Microsoft .NET: The Programming Bible
Computer
36.95
2000-12-09
Microsoft's .NET initiative is explored in detail in this deep programmer's reference.

-
O'Brien, Tim
MSXML3: A Comprehensive Guide
Computer
36.95
2000-12-01
The Microsoft MSXML3 parser is covered in detail, with attention to XML DOM interfaces, XSLT processing, SAX and more.

-
Galos, Mike
Visual Studio 7: A Comprehensive Guide
Computer
49.95
2001-04-16
Microsoft Visual Studio 7 is explored in depth, looking at how Visual Basic, Visual C++, C#, and ASP+ are integrated into a comprehensive development environment.



(a)audio file name is >> bk101.mov which is defined as a book id in xml file , now i want to change it to computer.wav (which is in genre tag under book id tag of bk101)

thank you You revived a 4 year old thread. You need to start your own thread.
5678.

Solve : Help with MSDOS batch files please?

Answer»

Years ago I was an expert with MSDOS batch files - but revisiting the subject from XP has given me an insoluble problem.

I have written a small simple batch file to read selected files on specified folders - this worked well. However, I tried to find a way to increase the size of the DOS window from its small opening default.

At the top LEFT of the original small window was an icon which accesses VARIOUS properties, including the option for full screen. Since implementing this, my batch file result in a full-screen window from which I cannot ESCAPE back into XP without killing it in Task Manager. The window just repeats itself, despite EXIT (or QUIT). Interrupting with Ctrl-C makes no difference.

If I INVOKE Run -> CMD the same happens, unless I Run -> cmd /k

Any advice would be appreciatedStart > Programs > Accessories > Right Click Command Prompt and select properties.
Select the options tab.
Under Display Options select Window

Alt + Enter should toggle the full screen mode as well.Squashman,

Many thanks - you are spot on. I imagined I was locked in a recursive DOS nightmare - took me back 30 years. At least in those days if something went wrong I had a chance of discovering it for myself - a bit like the days when I could repair a car with a WET finger and a large hammer.

Most grateful

Philip

5679.

Solve : A little question?

Answer»

Quote from: ghostdog74 on April 12, 2008, 08:07:38 PM

i presume you are learning how to program. if you are, choose a better language.

I think TCL is an interesting language.
Quote from: Dias de verano on April 13, 2008, 01:09:48 AM
Quote from: ghostdog74 on April 12, 2008, 08:07:38 PM
i presume you are learning how to program. if you are, choose a better language.

I think tcl is an interesting language.

yes it is, and so are many OTHERS. Yes... my point is "whatever floats your boat"

umm im not learning. i know a little c++ delphi batch html and started for fun Just BASIC
but i never used setlocal so i have problems with thatsince you have tried BASIC, how about a vbscript.
CODE: [Select]For i=1 To 10
For J=1 To 10
For k=1 To 10
var1 = (i*i) + ( j*j)
varR = k*k
If varR = var1 Then
WScript.Echo var1 & " " & varR & " " & k
End If
Next
Next
Next
save as script.vbs and on command line
Code: [Select]c:\test> cscript /nologo script.vbs
hmm. i DONT know specialy vbs but i think i must be
Code: [Select]For i=1 To 10
For j=1 To 10
For k=1 To 10
varl = (i*i) + ( j*j)
var1 = i
var2 = j
varR = k*k
If varR = varl Then
WScript.Echo var1 & " " & var2 & " " & k
End If
Next
Next
Next and i dont need to do this c:\test> cscript /nologo script.vbs
5680.

Solve : help me pls...?

Answer»

Hello everyone.
I need some help editing and opening text file using bat.

I need to get something like:
you type text in bat file -> it saves to text file

when you need to load text just goto load and type text you entered before -> then it does something

echo yourtext>>fileOk now i have line in the text file how can i see in bat file?

and if [line1 is ....] goto ....
how to do it?ok in this example the name of the text file is h, and will work with multiple lines as LONG as one of them is the line.

for /f "tokens=1*" %a in (h.txt) do if "%a"=="example" Goto Test1

remember to add another percent sign if you use this in a batch file, if you use it in the command window you only need to use one percent symbol on the %a tokens, but in a batch file you need two %%a.

you could also use this in an array, for example

for /f "tokens=1* delims=" %%a in (h.txt) do (
call set /a idx=%%idx%%+1
call goto test1
)
i am to dum to figure it out how it works Ok i figured out how it works but i need something to show whats in the text file
And thx for helpok, you can get information from the file by typing type filename.txtThankyou!By the WAY i want somehow instert lines in to choices
if it is POSIBLE...

@ECHO OFF



:Main
CLS
echo.
echo.
echo Welcome.
echo Chose:
echo Save=1
echo Load=2
echo Exit=0
echo.

SET /P MAIN= Chose...

If '%MAIN%'=='1' Goto Save
If '%MAIN%'=='2' Goto Load
If '%MAIN%'=='0' exit

echo There is no "%MAIN%" in the code...
pause
CLS
Goto Main



:Save
CLS
echo Lines inside file:
echo.
type text.txt
echo End of file.
echo.
echo Your text here:
SET /P SAVES= Enter save name...

echo %SAVES%>>text.txt
echo Saved...
pause
Goto Main



:Load
CLS
echo Lines inside file:
echo.
type text.txt
echo End of file.
echo.
SET /P LOADS= Chose what to load...


IF '%LOADS%'=='[text file 1st line]' goto l1
IF '%LOADS%'=='[text file 2nd line]' goto l2
IF '%LOADS%'=='[text file 3th line]' goto l3
IF '%LOADS%'=='[text file 4th line]' goto l4
IF '%LOADS%'=='[text file 5th line]' goto l5
IF '%LOADS%'=='[text file 6th line]' goto L6

use something similar to the array example i showed you

@echo off
set idx=0
for /f "tokens=1* delims=" %%a in (h.txt) do (
call set /a idx=%%idx%%+1
call set e.%%idx%%=%%a
)


IF '%LOADS%'=='%e.1%' goto l1
IF '%LOADS%'=='%e.2%' goto l2
IF '%LOADS%'=='%e.3%' goto l3
IF '%LOADS%'=='%e.4%' goto l4
IF '%LOADS%'=='%e.5%' goto l5
IF '%LOADS%'=='%e.6%' goto l6

5681.

Solve : Batch code problem; prevmonth=-1????

Answer»

Hey guys,

Me and my friend have a little problem. We are trainees and we have to create a batch file that does the following:

The first day of a new month it has to put all the .xml files in one .rar file with the year and the month number. Example: 2008_01.rar = January 2008

My friend completed most of it but he isn't doing something right. This is the code right now:


Code: [Select]@echo off
@For /F "tokens=2,3,4 delims=/ " %%A in ('Date /t') do @(
Set Month=%%A
Set Day=%%B
Set Year=%%C
)

cd c:\"Program Files"\Winrar

set /a prevmonth=month-1

rar a -tb%year%-%month%-01 C:\%year%_%prevmonth%.rar "C:\auto archive\*.xml"


del "C:\auto archive\*.xml"

pause


The problem is when a new month begins, it does -1. So Februari is 02, in the .rar file it becomes 01 (January)
But when you create a file that has been made in December. And you set the clock again to January and we run the batch file. It makes a .rar file but with this name: 2008_0, but it should be 2007_12
Another problem occurred with the month July and August. Then it becomes 2008_-1!

Would SOMEBODY please help us with this ?
Best way would be to add year-end logic:

Code: [Select]@echo off
For /F "tokens=2,3,4 delims=/ " %%A in ('Date /t') do (
Set Month=%%A
Set Day=%%B
Set Year=%%C
)

set /a month=%month%-1
if %month% equ 0 (
set month=12
set year=%year%-1
)

cd c:\"Program Files"\Winrar
rar a -tb%year%-%month%-01 C:\%year%_%prevmonth%.rar "C:\auto archive\*.xml"
del "C:\auto archive\*.xml"
pause

I cannot find the error for July & August. You don't have a special logic for those months. Can you post how the error occurs for those months?

I've made a screenshot of the DOS box while using your code:


I've mad a .xml file but he only deleted it It didn't make a .rar file in the C: directory...1. I don't know why people have to chop up the date string using a FOR loop and tokens when it is simpler just to slice %date%.

2. The date string is different in different locales. Here in EUROPE, my date string today is

Code: [Select]07/04/2008
I am presuming that both the OP and Sidewinder live in locales where the US type date format applies, viz:

Code: [Select]Day MM/DD/YYYY
So today would be

Code: [Select]Mon 04/07/2008
Is that correct?

In that case, why not just do this

Code: [Select]set /a month=%date:~4,2%
set /a year=%date:~10,4%
3. Beware, because set /a has some hidden TRAPS. For one thing, it interprets numbers with a leading zero as being octal numbers. That is why the problem happens in August, because as you know, 08 (and 09 as well) don't exist in octal.

Therefore, for months with a leading zero, it is best to test if the first character is a zero, and if so, lose it.

4. This won't work

Code: [Select]rar a -tb%year%-%month%-01 C:\%year%_%prevmonth%.rar "C:\auto archive\*.xml"
Because RAR says this

Code: [Select]<switches>
tb<date> Process files modified before <date> in YYYYMMDDHHMMSS format





The company is in Holland yes, but everything is set for the US. So also the dates have to be in that way. I believe then it would be like this:

month/day/year

So i replace the tokens part with this code:

Code: [Select]set /a month=%date:~4,2%
set /a year=%date:~10,4%Try this - assuming %date% format is mm/dd/yyyy

Code: [Select]set /a month=1%date:~,2%-100 %this removes the leading zero if value <10%

set /a year=%date:~-4%
Good luckI have no IDEA what i'm doing wrong

I've created some .xml files in the right directory, i've planted your code in the batch file but still it refuse to created a .rar file in de C: directory... All it does is deleting the .xml files...

This is the code right now:

Code: [Select]@echo off
@For /F "tokens=2,3,4 delims=/ " %%A in ('Date /t') do @(
Set Month=%%A
Set Day=%%B
Set Year=%%C
)

cd c:\"Program Files"\Winrar

set /a month=1%date:~,2%-100

set /a year=%date:~-4%

rar a -tb%year%-%month%-01 C:\%year%_%prevmonth%.rar "C:\auto archive\*.xml"

del "C:\auto archive\*.xml"

pause

-tb%year%-%month%-01

read what I wrote before
use a language that does date arithmetic better than batch. here's a vbscript
Code: [Select]strMonth=DatePart("m",DateAdd("m",-1,Date))
If Len(strMonth) <= 1 Then
strMonth = "0"&strMonth
End If
strYear = Year(Date)
If strMonth = "12" Then
strYear=strYear-1
End If
strCmd = "rar a -tb " & strYear & "-" & strMonth & ".rar " & """" & "C:\auto archive\*.xml" & """"
WScript.Echo strCmd
Set WshShell = CREATEOBJECT("WScript.Shell")
Set oExec = WshShell.Exec(strCmd)
Do While oExec.Status = 0
WScript.Sleep 100
Loop
WScript.Echo oExec.Status
save the above as script.vbs and on command line;
Code: [Select]c:\test> cscript /nologo script.vbs
I posted this some while ago (and repeated it)

This won't work:

rar a -tb%year%-%month%-01 C:\%year%_%prevmonth%.rar "C:\auto archive\*.xml"

Because RAR /? says this

<switches>
tb<date> Process files modified before <date> in YYYYMMDDHHMMSS format


5682.

Solve : hard drive crashed?

Answer»

hello. i was wondering if anyone could help me. i have a dell/gateway COMPUTER with windows ME and MS-DOS 6.0. my MOM said it crashed on her when she was playing a game, and i wasn't there when it happened. but when i turn on the computer, all i get is a file C that is totally USELESS...i tried getting bask to windows ME, but had no luck. all we have is a black screen with C:\>....or something like that. sorry. i don't REMEMBER what it says.
how do i get back tp windows?You can try this...
At the C: prompt type CD\Windows and hit Enter
At the next prompt it should read C:\Windows...type win and hit Enter.You should try typing this in after the C prompt: first type "chkdsk" let it do a check disk to check your harddrive and file format info. Reboot and SEE if that fixed it. After that try this "fixboot" if it asks are you sure type either "y" or "yes" most likely "y" and hit enter. reboot and see if that works. So... type "C:\chkdsk" hit enter. And "C:\fixboot" and hit enter. (of course with no quotation marks around any of this) there is also the possibility none of these will work if that's the case try using your windows disc's command repair option and type these in.

5683.

Solve : Batch File folder move?

Answer»

Let me start by saying, I'm VERY new to writing batch files. Here's my situation:

Each user on the domain has a personal FOLDER as well as a shared team folder where they store their data. The folder is located on a server. I have mapped the server to each user using AD. Every user is using windows 7.

I'm trying to write a script where when each user logs ONTO the domain, the script copies the personal folder as well as the shared team folder to their desktop.

This is what I've tried to use but unfortunately it doesn't WORK. Again, I'm extremely new to batch files so I may be on the wrong track. Help?

copy /-y "Z:\personalparentfoldername\personalsubfoldername" "C:\users\nameofuser\desktop"
pauselook at using XCOPY, copy only targets single files. If that doesn't work out, try robocopy. I honestly can't remember what the differences are, but I know one of them will work for you.

5684.

Solve : xcopy and "insufficient memory"?

Answer»

I made a simple series of batch files (SERIOUSLY, simple) to backup my flash drive. They worked for a while, but now the copying stops EARLY and "insufficient MEMORY" is displayed before the next file in the series (which prints the date in a text file) runs.

Why does this happen? How do I FIX it? Why am I too stupid to solve my own problems?

I would GREATLY appreciate any and all help with the above-mentioned questions.You are not "too stupid" by any means, although you should perhaps have guessed that typing...

Code: [Select]xcopy insufficient memory
...into Google might be a good first step. It would have told you what you needed to know, namely that with xcopy there is a limitation of 254 characters in the fully qualified file name which is the driver letter, full directory path and file name. More than this and you get the problem you describe. Maybe this is the reason?

It would also have told you that a program called xxcopy does not have this and other limitations, that it accepts xcopy commands and does a lot more as well. Put it somewhere on your PATH and you can just add an x to the beginning of 'xcopy' in batch files you already have, and that you can get a free version at:

http://www.xxcopy.com/index.htm



Thanks, I'll give that a shot.

Just for the record, I am exceptionally irritated with Google, since they disabled my Adsense account because to external entities, all the computers at my school have the same IP, leading Google's software to reach the conclusion that I was mass-clicking by myself.

5685.

Solve : batch file solution?

Answer»

i want to create a batch FILE from command cmd " for %i in (user1 user2 user3 user4 user5) do net user /ADD %i " this command to create user windows as much as 5, what is the SOLUTION ?
You aren't adding a password, or PROMPTING for a password.just only user, no add a passwordWhat question are you asking exactly?

5686.

Solve : Insufficient Memory with Xcopy on Win 7 of 750GB HDD 600GB data to 3TB ext drive?

Answer»

Trying to backup my Z: drive to an external and got a Insufficient Memory error using xcopy. Anyone know of a work around for this? Is there a way to see what file might be causing the condition etc.

Drive is 750GB and it has about 600GB of data to backup to a 3TB external which has PLENTY of free space.

Quote

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

Z:\>xcopy *.* e:\2015z\*.* /s/d/y
Insufficient memory
0 File(s) copied

Z:\>

System has 4 GB DDR2 RAM, and 2.3GB free with Windows 7 with Firefox and command shell running.Most likely cause is that one or more of the paths you tried to copy is longer than 254 characters.

Workaround is to use Robocopy.

Seems this has been asked before as well, and Salmon Trout gave effectively the same answer.If you are using xcopy with the /F switch you get logging on screen so you can see where the trouble starts. The problem can occur if the fully qualified name of either a source or POTENTIAL destination file exceeds 254 characters. As BC_P says, you can use Robocopy (Microsoft, free) or XXCopy (free for non-commercial use). There is also the "subst trick" where you substitute a spare drive letter for some part of a problem path e.g. subst z: \\myopenbsdbox\daily-backups\username\computername\C\. Quote
If you are using xcopy with the /F switch you get logging on screen so you can see where the trouble starts.

Thanks for the info. I wasnt aware of using the /F switch as a way to display error condition cause as for xcopy normally displays the files being transferred anyways and so I always thought the /F switch was useless. Was thinking I might have exceeded a maximum file size supported by xcopy vs path length.

So Robocopy will allow exceeding the 254 character limit if thats the case here? I wasnt aware of that robocopy supported greater than 254 characters in path length.


Quote
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Users\dave>xcopy/?
Copies files and directory trees.

XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W]
[/C] [/I] [/Q] [/F] [/L] [/G] [/H] [/R] [/T] [/U]
[/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z] [/B]
[/EXCLUDE:file1[+file2][+file3]...]

source Specifies the file(s) to copy.
destination Specifies the location and/or name of new files.
/A Copies only files with the archive attribute set,
doesn't change the attribute.
/M Copies only files with the archive attribute set,
turns off the archive attribute.
/D:m-d-y Copies files changed on or after the specified date.
If no date is given, copies only those files whose
source time is newer than the destination time.
/EXCLUDE:file1[+file2][+file3]...
Specifies a list of files containing strings. Each string
should be in a separate line in the files. When any of the
strings match any part of the absolute path of the file to be
copied, that file will be excluded from being copied. For
example, specifying a string like \obj\ or .obj will exclude
all files underneath the directory obj or all files with the
.obj extension respectively.
/P Prompts you before creating each destination file.
/S Copies directories and subdirectories EXCEPT empty ONES.
/E Copies directories and subdirectories, including empty ones.
Same as /S /E. May be used to modify /T.
/V Verifies the size of each new file.
/W Prompts you to press a key before copying.
/C Continues copying even if errors occur.
/I If destination does not exist and copying more than one file,
assumes that destination must be a directory.
/Q Does not display file names while copying.
/F Displays full source and destination file names while copying.
/L Displays files that would be copied.
/G Allows the copying of encrypted files to destination that does
not SUPPORT encryption.
/H Copies hidden and system files also.
/R Overwrites read-only files.
/T Creates directory structure, but does not copy files. Does not
include empty directories or subdirectories. /T /E includes
empty directories and subdirectories.
/U Copies only files that already exist in destination.
/K Copies attributes. Normal Xcopy will reset read-only attributes.
/N Copies using the generated short names.
/O Copies file ownership and ACL information.
/X Copies file audit settings (implies /O).
/Y Suppresses prompting to confirm you want to overwrite an
existing destination file.
/-Y Causes prompting to confirm you want to overwrite an
existing destination file.
/Z Copies networked files in restartable mode.
/B Copies the Symbolic Link itself versus the target of the link.
/J Copies using unbuffered I/O. Recommended for very large files.

The switch /Y may be preset in the COPYCMD environment variable.
This may be overridden with /-Y on the command line.

C:\Users\dave>
https://en.wikipedia.org/wiki/Robocopy

Quote
Features

Robocopy is noted for capabilities above and beyond the built-in Windows copy and xcopy commands, including the following:

Ability to tolerate network interruptions and resume copying. (incomplete files are marked with a date stamp of 1970-01-01 and contain a recovery record so Robocopy knows where to continue from)

Ability to skip NTFS junction points which can cause copying failures because of infinite loops (/XJ)

Ability to copy file data and attributes correctly, and to preserve original timestamps, as well as NTFS ACLs, owner information, and audit information using command line switches. (/COPYALL or /COPY:) Copying folder timestamps is also possible in later versions (/DCOPY:T).

Ability to assert the Windows NT "backup right" (/B) so an administrator may copy an entire directory, including files denied readability to the administrator.

Persistence by default, with a programmable number of automatic retries if a file cannot be opened.

A "mirror" mode, which keeps trees in sync by optionally deleting files out of the destination that are no longer present in the source.

Ability to skip files that already appear in the destination folder with identical size and timestamp.

A continuously updated command-line progress indicator.

Ability to copy file and folder names exceeding 254 characters — up to a theoretical limit of 32,000 characters — without errors.

Multithreaded copying. (Windows 7 and Windows Server 2008 R2)

Return code on program termination for batch file usage.
Thanks for the info on robocopy ... and 32,000 character length is insane...LOL

Robocopy did solve the problem btw... thanks It's likely that with all the PC's you work on a 32,000 character limit is not out of the realm of possibilities...
5687.

Solve : HandbrakeCLI: use same target file name as source file name?

Answer»

Hi,
I'm using Handbrake to encode video file. To encode with Handbrake I have to tell Handbrake where it finds the source file and what's the name of the encoded file.
e.g. HandbrakeCLI.exe -i f:/RecordedTV/Hangover.TS -o f:/RecordedTV/Hangover.mkv
Hangover.TS is the source file
Hangover.mkv is the encoded file
Next time I probably will encode Hangover2.TS
So I have to use
HandbrakeCLI.exe -i f:/RecordedTV/Hangover2.TS -o f:/RecordedTV/Hangover2.mkv

So how can I read the file name (here it is e.g. "Hangover" or "Hangover2") and use this file name in a variable way?

I hope you all understand what I mean :-)
In a batch file variables have percent signs before and after like this %filename% so you could do something like this

Code: [Select]set filename-Hangover
HandbrakeCLI.exe -i f:/RecordedTV/%filename%.TS -o f:/RecordedTV/%filename%.mkv
You can use the SET command to assign a variable value like above or SET /P to ASK for a filename like this

Code: [Select]set /p filename="Please input the file name? "
Or you could pass the name as a replaceable parameter to the batch from the command line like this

Encode.bat:

Code: [Select]set filename=%~1
HandbrakeCLI.exe -i f:"/RecordedTV/%filename%.TS" -o f:"/RecordedTV/%filename%.mkv"
Command line: Encode.bat Hangover or Encode.bat "Name with spaces"








Quote from: Salmon Trout on September 19, 2015, 12:01:30 PM

In a batch file variables have percent signs before and after like this %filename%
There are some others with exclamation marks but we don't need to go there right now.
Sorry but you didn't understand what I mean (ENGLISH is not my first language).
I use a media center software with infrared remote control. No keyboard. Inside this software I press a button to start handbrake. By pressing this button this commands will be send:
handbrakecli.exe -i f:/videos -o f:/videos/movie.mkv
"-i" means INPUT. "-o" means OUTPUT. So handbrake is searching for a TS file inside the folder "videos" and then encodes to mkv format. THe encoded movie gets the name "movie.mkv". That means: everytime I start an encoding process the mkv movie gets the name "movie.mkv". That's bad.
ALso I can send this

handbrakecli.exe -i f:/videos/hangover.ts -o f:/videos/hangover.mkv
Thats means: handbrake only encodes the movie hangover.ts to hangover.mkv

Now I need an automatically detection of the movie name.

Something like this:
handbrakecli.exe -i f:/videos/%filename%.ts -o f:/videos/%filename%.mkv

But at this point the variable %filename% is empty. So: how can I prior to that store the the movie name in the variable %filename%.

I think I need a batch that looks inside the folder "videos" for a movie in TS format and when there is a movie then the movie name needs to be STORED in the variable %filename%. But how can I acchieve this?

olli14
The FOR command can list all the files in the directory.
Code: [Select]FOR %%G in (*.ts) do echo %%G[code]To expand on Squashman's code:

Code: [Select]@echo off
FOR %%G in ("f:\videos\*.ts") do "handbrakecli.exe" -i "%%~G" -o "%%~nG.mkv"It's working great. Thanks.
5688.

Solve : identify & delete zero byte files from a directory?

Answer»

Hello. If anyone can help me with this issue:

I'm trying to create a batch that will delete any files from a network drive that are Zero bytes.

Notes:
1. This doesn't run from a batch file, but runs from a command prompt (with the single %)
2. It appears that the ~z doesn't work because it deletes ALL the files from the directory.

Script:
FOR %%F IN (UNC Path) DO IF %%~zF equ 0 DEL %%F

Any help would be great.

Thanks... GTHello.
Some questions.
Why would you want to do this? If a file has a least 1 byte, would it be somehow better or more useful?
If you do not like a zero byte file, Why did you make them?
If you did not make them, who did? And Why?

My point is that a zero byte fie make have an important reason for being in a directory.
Let me suggest you first make a list of all the zero byte files before you delete them. You might change your mind.
Reference:
https://en.wikipedia.org/wiki/Zero_byte_file
QUOTE

Zero byte file
From Wikipedia, the free encyclopedia
A zero byte file or zero length file is a computer file containing no data; that is, it has a length or size of zero bytes.
It goes on to say:
Quote
n some cases, zero byte files may be USED to convey information like file metadata (for example, its filename may contain an instruction to a user viewing a directory listing such as documents-have-been-moved-to-partition-D.txt, etc); or to put in a directory to ensure that it is nonempty, since some tools such as backup and revision control software may ignore the empty directories.
The filename itself can be a for of metadata.
Quote
metadata
a set of data that describes and gives information about other data.
Because you are asking it too look at the directory and not any of the files in the directory. If the directory is empty it will be zerobytes and delete the directory.

From the cmd prompt. Double the percent signs if you want to run this in a batch file.

Code: [Select]H:\zerobyte>dir /a-d
Volume in drive H is DATA
Volume Serial Number is D2F3-49FA

Directory of H:\zerobyte

07/22/2016 01:08 PM 1 onebyte.txt
07/22/2016 01:08 PM 2 twobyte.txt
07/22/2016 01:05 PM 0 zerobyte1.txt
07/22/2016 01:05 PM 0 zerobyte2.txt
07/22/2016 01:05 PM 0 zerobyte3.txt
5 File(s) 3 bytes
0 Dir(s) 124,020,506,624 bytes free

H:\zerobyte>for %G in (\\SERVER\SHARE\Squashman\zerobyte\*) do @if %~zG equ 0 @echo delete %G
delete \\SERVER\SHARE\Squashman\zerobyte\zerobyte1.txt
delete \\SERVER\SHARE\Squashman\zerobyte\zerobyte2.txt
delete \\SERVER\SHARE\Squashman\zerobyte\zerobyte3.txt

H:\zerobyte>There's a script that runs on another system that places an error file into an ERROR_Logs folder. Many times, a zero byte file is generated. (I'm working on figuring out why this process is doing this.) I also have a UC4 monitor on this folder, that sends a notification if any files are in this folder for more than 1 hour. (another area where I'm trying to exclude zero byte files. In the mean time, I thought it would be easier to use a batch to delete any zero byte files, until the other STUFF can be sorted out.

Hope this answers your question.

Quote from: Geek-9pm on July 22, 2016, 09:59:40 AM
Hello.
Some questions.
Why would you want to do this? If a file has a least 1 byte, would it be somehow better or more useful?
If you do not like a zero byte file, Why did you make them?
If you did not make them, who did? And Why?

My point is that a zero byte fie make have an important reason for being in a directory.
Let me suggest you first make a list of all the zero byte files before you delete them. You might change your mind.
Reference:
https://en.wikipedia.org/wiki/Zero_byte_fileIt goes on to say:The filename itself can be a for of metadata.
Quote from: Geek-9pm on July 22, 2016, 09:59:40 AM
Why would you want to do this? If a file has a least 1 byte, would it be somehow better or more useful?
If you do not like a zero byte file, Why did you make them?
If you did not make them, who did? And Why?

Geek, the task of deleting zero byte files is the very clear question and it's also clear that the OP has a reason to do so.
Quote
I'm trying to create a batch that will delete any files from a network drive that are Zero bytes.

I chose to interpret that as every zero byte file on the drive.

I added the recursive switch here and support for long filenames.
Remove this portion if Squashman's code below shows the right things on your screen.
@echo found filesize "%~zG" in file "%G" & @echo

The same code will work for a single folder as in Squashman's post if you remove the /R switch and it is the double quotes around the "%G" that allows it to handle long filenames and long pathnames.

Code: [Select]for /r %G in (\\SERVER\SHARE\*) do @if %~zG equ 0 @echo found filesize "%~zG" in file "%G" & @echo delete "%G"
5689.

Solve : Nested ifs and fried brain?

Answer»
I think I should know how to do this but I have forgotten too much of the nuances of the command prompt. I'm trying to dream up a condition statement for a host of possibilities, like deleting certain files but only those files. The first thought I had was along the lines of IF EXIST 000?.* DEL 000?.* ELSE - And that is where I am falling down on the job. To KEEP the example simple let's SUPPOSED an ascending list of in numeric order. So after the ELSE I would like to have it CHECK the next higher group as in IF EXIST 001?.* DEL 001?.* ELSE . . . .

Basically I am wanting to build a really ugly next or compound IF statement. Now since this is supposed to happen in ascending or descending order it should be simple to just change the numerical condition if but I am stuck on this complex IF statement. I got out of the computer business about the time "scripts" were taking the PLACE of "Batch" files so Robo-powershell-whatever-it-is-called isn't really an option for me. I'd appreciate any suggestions. Some details.
How many files?
Why do you need to remove them?
Would it not be better to send older files to a archive folder?
Why sound sending order make any difference?


Are you using IF EXIST before DEL filemask purely so that you don't get a 'file not found' error message if nothing matches filemask? Or is it important for some other reason to know if filemask exists? Will this affect what you do (or don't do) next? Because if your logic is like this:

If any files matching filemask1 exist, delete them
if not...
If any files matching filemask2 exist, delete them
if not...
If any files matching filemask3 exist, delete them
(etc)

... then you don't really care about the 'if nots', do you?

Basically I'm asking, why do you need IF EXIST or ELSE at all?

The folder in question has a few thousand graphic files and a program sequentially goes the folder and displays the next graphic in the list for a few minutes and goes to the next one. Unfortunately the program isn't bright enough to keep track of where it is in the list and after every restart, it starts with the first file. The files are all copies of files in a folder on a different drive so it is easy to replenish the folder "feeding" the program.

For right now I attempt to remember to check that folder on a restart and delete out what seems like would be a reasonable number from the beginning. That way I don't have the same hundred files pictured over and over again. So I am looking for a way to delete some number of files, maybe a hundred, on a restart but without having to remember to do so. For example if file 0100 exists then I could delete 01?? but then I want it to stop. I don't want it to check for 0200 because I would have just deleted files 0100 through 0199. If after running the program for a while, deleting 100 files might seem too high or too low, then I could adjust the batch file IF statements accordingly.

On the first running of the batch file it should FIND and delete the first hundred file and break out of the if statement. On the second running of the program it would find no matching files of the first hundred and skip to the next conditional statement; which would prompt about the next hundred and so on. By the time you have a thousand files deleted, the program would need to past through ten if statements which would all be not true but the eleventh one would be true.

This is just an exercise in mental gymnastics to keep the brain from freezing up, it is not serious. But it has turned out to be tougher than I anticipated. I gave some consideration to reversing the logic to not exist but that didn't seem to make the task any easier.
Quote from: rmmccoy
On the first running of the batch file it should find and delete the first hundred file and break out of the if statement. On the second running of the program it would find no matching files of the first hundred and skip to the next conditional statement; which would prompt about the next hundred and so on. By the time you have a thousand files deleted, the program would need to past through ten if statements which would all be not true but the eleventh one would be true.
This is what I did:

1. Create 1000 test files (I made .txt files but the extension is immaterial, you can change this) in blocks of 100 named 0000.txt to 0099.txt, 0100.txt to 0199.txt ... ending 0900.txt to 0999.txt

2. Each time it is run it deletes the first block in the sequence that exists, then quits.

3. If, on running, there are no files to delete, it informs the user and quits.

If you run batches by double clicking in Explorer, (i.e. not in a console window) you may want to put a PAUSE command as the last line.

@echo off
IF EXIST 00??.txt DEL 00??.txt & goto done
IF EXIST 01??.txt DEL 01??.txt & goto done
IF EXIST 02??.txt DEL 02??.txt & goto done
IF EXIST 03??.txt DEL 03??.txt & goto done
IF EXIST 04??.txt DEL 04??.txt & goto done
IF EXIST 05??.txt DEL 05??.txt & goto done
IF EXIST 06??.txt DEL 06??.txt & goto done
IF EXIST 07??.txt DEL 07??.txt & goto done
IF EXIST 07??.txt DEL 07??.txt & goto done
IF EXIST 08??.txt DEL 08??.txt & goto done
IF EXIST 09??.txt DEL 09??.txt & goto done
echo No files left!
:done
echo Finished

The same effect is produced by this:

@echo off
FOR /L %%N IN (0,1,9) DO IF EXIST 0%%N??.txt DEL 0%%N??.txt & GOTO done
ECHO No files left!
:done
ECHO Finished





You can have multline IF statements using brackets (parentheses) so that this:

IF EXIST 00??.txt DEL 00??.txt & goto done

is equivalent to this:

IF EXIST 00??.txt (
DEL 00??.txt
goto done
)

So you could do stuff like this

IF EXIST 00??.txt (
ECHO Deleting files: 00??.txt
DEL 00??.txt
goto done
)




Does the program take command line options at all?
If so then keeping track of where a script is up to in the list of files should be fairly easy.

Del can be tricky because when deleting using simple filemask it can delete files you don't want to delete, because del parses the short filenames too and not just the long filenames.Deleter4.bat:

@echo off
for /l %%N in (0,1,9) do if exist 0%%N??.txt echo Deleting files starting 0%%N00 & del 0%%N??.txt & goto done
echo No files left!
:done
echo Finished


Output of 11 runs, starting with a folder of 1000 files:

D:\testfolder\del100>deleter4
Deleting files starting 0000
Finished

D:\testfolder\del100>deleter4
Deleting files starting 0100
Finished

D:\testfolder\del100>deleter4
Deleting files starting 0200
Finished

D:\testfolder\del100>deleter4
Deleting files starting 0300
Finished

D:\testfolder\del100>deleter4
Deleting files starting 0400
Finished

D:\testfolder\del100>deleter4
Deleting files starting 0500
Finished

D:\testfolder\del100>deleter4
Deleting files starting 0600
Finished

D:\testfolder\del100>deleter4
Deleting files starting 0700
Finished

D:\testfolder\del100>deleter4
Deleting files starting 0800
Finished

D:\testfolder\del100>deleter4
Deleting files starting 0900
Finished

D:\testfolder\del100>deleter4
No files left!
Finished
5690.

Solve : How do I create a batch file script to run another batch file??

Answer»

Hi all! I'm new to computer programming and command lines in batches, so please be patient with me. I'm trying to set up my computer so that my wife and kids can just turn it on, click on an icon, and PLAY any game they want.

With games like Assassin's Creed I and II and Dark SOULS, you have to disable all of the HID-compliant game controllers other than an X360 controller before you can use it. To make this easy, I downloaded the "devcon" program from Windows. On my computer, its executable file is in C:\Program Files (X86)\Windows Kits\10\Tools\x64. I created a batch file in the same folder - "EnableXBOX1.bat" - that enables the X360 controller and disables the others. Then I created a batch file - "EnableAll.bat" - that enables all the controllers. Both these batch files work fine.

What I'm trying to do now is create a third batch file for my desktop (or for a shortcut from my desktop) that will (1) run the "EnableXBOX1.bat" file (to make the controller work), (2) run the game (which, say, is on my G drive), (3) on exiting the game, run the "EnableAll.bat" file (to get all the controllers enabled again) and exit.

This seemed simple to me, but I just can't get the bat files to run. I've tried the start and call commands, but something about my syntax has got to be wrong. Can anyone give me some syntax that would work to do this seemingly simple thing? Thanks so much!Since each game requires an .exe to start/run you would have to build them for each game as the paths are all different...Thanks, but yes, I know that. I'm asking what the command lines I would use.

For example, if I'm trying to have the batch file do the following, what's the actual syntax?

1) Run "C:\Program Files (X86)\Windows Kits\10\Tools\x64\EnableXBOX1.bat"
2) Run "G:\Darksouls.exe"
3) Run "C:\Program Files (X86)\Windows Kits\10\Tools\x64\EnableAll.bat"
Code: [SELECT]Call "C:\Program Files (X86)\Windows Kits\10\Tools\x64\EnableXBOX1.bat"
"G:\Darksouls.exe"
Call "C:\Program Files (X86)\Windows Kits\10\Tools\x64\EnableAll.bat"
Quote from: bacchuspup on July 15, 2016, 09:43:33 PM

Thanks, but yes, I know that. I'm asking what the command lines I would use.

1) Run "C:\Program Files (X86)\Windows Kits\10\Tools\x64\EnableXBOX1.bat"
2) Run "G:\Darksouls.exe"
3) Run "C:\Program Files (X86)\Windows Kits\10\Tools\x64\EnableAll.bat"


This modification allows you to call the script below say gamerun.bat
and in each shortcut for a game you can replace the target executable "c:\folder\gamefile.exe" with the line below and it should do the steps you want. This only requires the one gamerun.bat file but a side effect with a batch script in this way is that a cmd window will be on the taskbar during the gameplay.

Code: [Select]%comspec% /c "c:\folder\gamerun.bat" "c:\folder\gamefile.exe"

Code: [Select]@echo off
Call "C:\Program Files (X86)\Windows Kits\10\Tools\x64\EnableXBOX1.bat"
start "" /w %*
Call "C:\Program Files (X86)\Windows Kits\10\Tools\x64\EnableAll.bat"Thanks guys... I had tried the Call command before, but it didn't work before and it still isn't working, and I have no idea why.

To simplify things, I made a G drive file "DeviceManager" that holds devon.exe and EnableXBOX.bat. When I double-click on EnableXBOX.bat, I can tell it works, because it enables & disables the controllers as instructed.

Then I made a bat file in a separate G drive file. The only script I included in it was this:

Call "G:\DeviceManager\EnableXBOX.bat"

So if I run that bat file, it should run the "EnableXBOX.bat" file the same as if I had run it directly, right? Only it doesn't. None of the controllers are enabled or disabled in accordance with the EnableXBOX.bat commands.

I have no idea why the Call command in the second bat file isn't making the first bat file run. I'm going to try a work-around and just put the devcon.exe file in the same folder as the file with all my game SHORTCUTS. That way I shouldn't have to run a batch file from another batch file. But I wish I could figure out why I can't do this when it seems so simple.

For what it's worth, I'm on Windows 10.Well, my work-around worked... sorta. For the Dark Souls game, I just put this batch together in the same folder as devcon.exe:

@echo off
devcon enable "{Xbox controller}"
devcon disable "{the other HID controllers}"
"G:\darksouls.exe"
TIMEOUT /t 30
devcon enable "{the other HID controllers}"

This works - when I click on this batch file, the game starts with the proper controller enabled and the others disabled, then after 30 seconds enables the other controllers (I do this to make sure the game starts). As long as the game starts with the other controllers disabled, the X360 controller still works.

The only issue is that when the enable kicks in after the 30 seconds, it minimizes the game and shoots me back to my desktop. I know all I have to do then is click on the game icon again, but that's inelegant. Is there any way to have the script either execute the last instruction (1) after exiting the game, or (2) in the background, so it doesn't minimize the game?

Thanks again for the help!!!Quote
Then I made a bat file in a separate G drive file. The only script I included in it was this:

Call "G:\DeviceManager\EnableXBOX.bat"
Do you mean in a separate G drive folder? You need to put devcon.exe in that folder, or else include the full path to devcon.exe in EnableXBOX.bat. Otherwise it won't see devcon.exe.
Ah - okay, I think that makes sense. Still, now I think I need more the answer to my other question - which is whether there's any way to have the script

(1) disable the applicable controllers (which I now know how to do),
(2) start the game (again, I now know how to do), then
(3) enable the controllers without interrupting the game - either by waiting until exiting the game or by enabling them without minimizing the game.

It's #3 that I can't seem to figure out. Thanks.Does it do that for all games or just selected ones?
It's not a usual behaviour for command line tools and devcon itself may be the problem if all games do this.

You can place devcon.exe on the path and it will work from any folder.

C:\windows or c:\windows\system32 are fairly good spots for this.
5691.

Solve : set date in batch file,?

Answer»

Hi to hall.
my first post...

CODE: [Select]
: need to copy \\Myserverdir\File.txt to C:\mydir\Test_(date_creation).txt

setlocal

:: the following are what I used to test - change to yours!
SET folder=\\SynDS214\share
set file=File.txt
set target=D:\Backup

:: get the file's date as dd/mm/yyyy
for /f "tokens=1" %%a in ('dir "%folder%\%file%" ^| find /i "%file%"') do set filedate=%%a

:: change the date to yyyymmdd
set date_created=%filedate:~6,4%%filedate:~3,2%%filedate=~0,2%

:: perform the copy, if the file is not present in the target
if not exist "%target%\Test_(%date_created%).txt" ^
copy "%folder%\%file%" "%target%\Test_(%date_created%).txt"

:: check on the copied file
dir "%target%\Test_(%date_created%).txt"

endlocal


why the conversion od date return 201607 instead 20160712

really i nee, in other case, 2016-07-12Try /......Try /......

?yyyy/mm/ddGetting a stable date and time format is the most FAQ since MSDOS V1.0
The fact that MS still hasn't provided it in cmd.exe boggles my mind.

These give you a reliable date and time format.



Code: [Select]@echo off
rem The four lines below will give you reliable YY DD MM YYYY HH MIN Sec MS variables in XP Pro and higher.
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%" & set "MS=%dt:~15,3%"
set "datestamp=%YYYY%%MM%%DD%" & set "timestamp=%HH%%Min%%Sec%" & set "fullstamp=%YYYY%-%MM%-%DD%_%HH%-%Min%-%Sec%-%MS%"
echo datestamp: "%datestamp%"
echo timestamp: "%timestamp%"
echo fullstamp: "%fullstamp%"
pause

Code: [Select]@echo off
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "date-time=%dt:~0,4%-%dt:~4,2%-%dt:~6,2%_%dt:~8,2%-%dt:~10,2%-%dt:~12,2%"
echo date-time: "%date-time%"
pause

5692.

Solve : Batch file to disable Daylight saving time for remote machine?

Answer»

This may help you:

Code: [Select]c:\>tzutil /?
Windows Time Zone UTILITY

Usage:
TZUTIL </? | /g | /s TimeZoneID[_dstoff] | /l>

Parameters:
/? Displays usage information.

/g Displays the current time zone ID.

/s TimeZoneID[_dstoff]
Sets the current time zone using the specified time zone ID.
The _dstoff suffix disables Daylight Saving Time adjustments
for the time zone (where applicable).

/l Lists all valid time zone IDs and display names. The output will
be:
<display name>
<time zone ID>

Examples:
TZUTIL /g
TZUTIL /s "Pacific Standard Time"
TZUTIL /s "Pacific Standard Time_dstoff"

Remarks:
An exit code of 0 indicates the command completed successfully.The Windows Time Zone Utility is available as a download from MS.
http://www.microsoft.com/en-us/download/details.aspx?id=25166
However, it may have issues:
http://blogs.msdn.com/b/cjacks/archive/2009/12/16/windows-7-debugging-demo-troubleshooting-the-broken-microsoft-time-zone-utility.aspx
Here is a command line example:
http://stackoverflow.com/questions/16656229/how-do-i-set-the-timezone-from-command-line

Bear in mind that the eastern Europe usage is not universal. And in other areas also. This year is a real mind bender.

Daylight Saving Time Around the World 2015


Rather than pure batch, MANY administrators are using Powershell.
Powershell is in all current versions of Windows and has many features from the .NET library.
A few:
https://gist.github.com/chrisbenti/11036644
http://stackoverflow.com/questions/11035905/powershell-display-current-time-with-time-zone
https://technet.microsoft.com/en-us/library/hh849887.aspx
http://powershell.com/cs/blogs/tips/archive/2013/08/13/changing-current-time-zone.aspx
As can been seen, the scripts are not trivial. So pure batch may be very hard, if even possible. IMHO the Powershell scripts should be considered.

Sorry, I can not do the code for you. I am very slow to code. I takes me three days to do what some here can do in an afternoon.
Quote from: Geek-9pm on September 12, 2015, 10:01:53 PM

The Windows Time Zone Utility is available as a download from MS.
http://www.microsoft.com/en-us/download/details.aspx?id=25166
However, it may have issues:
http://blogs.msdn.com/b/cjacks/archive/2009/12/16/windows-7-debugging-demo-troubleshooting-the-broken-microsoft-time-zone-utility.aspx

You've made it very easy for me to check by providing the links - and those refer to downloads for XP (and server 2003).

Just commenting here if people stumble across this thread looking for info in the future, that it's not for current versions of Windows.

I do see that Abo-Zead is using XP though.Hope you can help him.
In non-western countries, the DST is more difficult.
Local conditions alter the way it is used. Microsoft is aware of the problem and has some information about how to fix it for Egypt this year.
Last year:
2014 - Egypt Ramadan DST changes - Fix it
This yer:
2015 - Egypt DST changes - hotfix
I found these with a Google on:
how does windows do DST in Egypt
It seems many administrators in Egypt have issues with DST.
Dear all,

thank you for your assistance and APPRECIATE that and after explore some pages that you provide it to me i understood a little of things And I hope that you read my post carefully well So i'll explain my issue again ( all machines have synchronized with the server in time but some times some machines lost this syncing and enable daylight saving time I mean +1 hour but all machines have the same time zone even the machines that lost syncing ( Egypt Standard Time ) and and i want to return the time as before by disabling daylight saving time or by any way so i did restart it remotely to re-syncing and nothing happened and create the batch attached to disable DST and restart it remotely and also nothing happened, only the remote access can do that but i want to do that by using remotely batch.
NOT: my created batch can disable DST for remotely machine but can't apply that actually as figures in the first post.
: machines have Windows XP SP2.

So Could any one create a batch to disable DST and apply that for remotely machine actually .

thanks again for your supportThis may be of interest:
http://www.timeanddate.com/worldclock/egypt/alexandria

Alexandria, Egypt does not use the DST of Cairo.
My guess is that Windows has some problem doing DST for Egypt. And remember that Windows XP is no longer supported by Microsoft.

Therefore, you may have to set all machines to Alexandria, Egypt. Doing so should SHUT off the DST.

I can not test this. Here is another reference:
https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/int_pr_custom_workspace_regionalsettings.mspx?mfr=true
From there go to the place where is says:
Change the way your computer displays the time

Speculation: Setting the time off by twenty minuets may cause the machine to sync again with the server.

Please keep us posted.

EDIT:
Try this Google search:
https://www.google.com/search?q=force+remote+XP++to+not+use+DST&ie=utf-8&oe=utf-8
It seems the XP DST trouble is not limited to Egypt or any location. It is impossible to turn off DST in Windows XP by remote. One of the links mentions Egypt, but the problem is also in other places.
http://itproafrica.com/technology/windows/disabling-daytime-savings-microsoft-windows-egypt-dst/
Dear all,

could any one help me to do this code " TZUTIL /s "Pacific Standard Time_dstoff" in remotely machine.

by batch file onlyQuote from: Abo-Zead on September 23, 2015, 10:18:44 PM
could any one help me to do this code " TZUTIL /s "Pacific Standard Time_dstoff" in remotely machine.
by batch file only

What remote access software can be used? PSEXEC?

Edit:

It looks like tzutil is not a tool that you can use on XP.

https://technet.microsoft.com/en-us/library/hh825053.aspx
Applies To: Windows 8, Windows 8.1, Windows Server 2012, Windows Server 2012 R2
5693.

Solve : BAT file to Detect file size and rename?

Answer»

Hi,

I want to create a BAT file which will detect file size for specific file and rename it if file size exceeds 10mb.

file name is OraEss.log and new name should be OraEss.old

Please help me with this.

Thank you.Some concerns... its a log file and is it always in use by the service that write to this log file?

I see what your trying to accomplish, but it might only be able to be accomplished if the log file is not in use by the program/service that has it 'file open' in the programs code. If the program/service has a 'file close' statement in it code then a batch could rename it while its closed. However you will get an error if trying to rename a file that is in use.

Your batch might require running a DIR command and PARSING for file size and then when file size exceeds 10MB then kill the service/program which could have negative impacts such as database corruption if a database is writing data to tables etc when the program/service is killed and then rename file and then restart the program/service.

I had a similar issue with a TeamPOS point of sale system where server logs were climbing in size. The fix was to stop the service at 23:59 when the database was quiet with no ACTIVITY, create a folder named that days date, stop the mysql database service properly, then stop the program from writing to log file, and move the log file to a folder. Then restart the services at MIDNIGHT and have this as a scheduled task on the server. This then caused log files to be easier to manage and only 500k in size vs growing into the 20+ meg range when notepad freaks out when trying to view them etc.

What SOFTWARE or service is writing so we know its nature to know best way to assist with this?

* If a database is involved which most of the time is these days you will need to gracefully stop the database before killing the program/service to avoid problems.A question: what do you want to happen if OraEss.old already exists?

Something along these lines ought to work...



Enclosed Code removed upon Authors request...

Do NOT USE the above code! I made a BAD ERROR! I used the overwrite operator instead of the append one in the file-in-use test. This would be destructive of data! Please see below.

@echo off
REM You can find a file size using FOR
for %%A in (OraEss.log) do set fsize=%%~zA
REM use 10000000 if you want decimal megabytes
REM use 10485760 if you want binary megabytes
if %fsize% LSS 10000000 goto end
REM if the file is not in use you can append a newline to it
:loop
echo. >> OraEss.log && (
ren OraEss.log OraEss.old
goto end
)
REM wait 5 to 6 seconds
PING 1.1.1.1 -n 1 -w 60000 >NUL
goto loop
:endImproved file-in-use detection (does not alter file):

@echo off
for %%A in (OraEss.log) do set fsize=%%~zA
REM use 10000000 if you want decimal megabytes
REM use 10485760 if you want binary megabytes
if %fsize% lss 10000000 goto end
REM if the file is not in use you can append to it
REM Append NUL (i.e. nothing)
:loop
(type nul >> OraEss.log) 2>nul && (
ren OraEss.log OraEss.old
goto end
)
REM wait 5 to 6 seconds
PING 1.1.1.1 -n 1 -w 60000 >NUL
goto loop
:end

5694.

Solve : Split big Dos/windows text file into smaller multiple Unix text files??

Answer»

First of all i using WINDOWS OS and not LINUX,all i want is to Split a big file from Dos/windows text file into smaller multiple Unix text files?All tools i tried,they spliting from dos/windows format to dos or from unix to dos,i want a tool,a bat, a command line,anything to split from dos or unix to unix

5mb.txt(unix or dos format)--> split in 705 pieces Unix format (80 kb each)

thank you1. Windows port of dos2unix

http://waterlan.home.xs4all.nl/dos2unix/dos2unix-7.3.4-win32.zip

2. GNU Utilities (contains split.exe Windows port of Unix split utility)

http://gnuwin32.sourceforge.net/downlinks/coreutils-bin-zip.php





Yes you need to look into the unix commands and Linux commands and become familiar with the tools that can break large files into smaller files you would use something like her said or perhaps GRIP. Oops, I meant to say grip grip who on this speech recognition thing. What I wanted to say is there Unix utility that can work on a text file and break it up into many pieces I believe it's called TRAP. Crypt no crap oh crap. No lie or or Linux utilities that can do what you want. Then after you get the files broken into smaller things there is some sort of way to convert it into the the type of file most often USED by Windows editors. Something about the Line Feed and carriage return combinations. But that's a trivial point. What is tough is to find a text editor or utility that can handle the huge size that you are asking for. Off the top of my head I don't know if I can be done and said I meant to say SED not setHow do you want your files split?

It it using an exact filesize? Before or after the conversion to Unix?
Unix uses a FEWER number of characters after the change in line endings.

Or do you want a certain number of lines in each file?


I'm asking the questions because your lines could be cut in the middle of a word if you simply specify a filesize.

Quote from: foxidrive on July 06, 2016, 02:20:50 AM

How do you want your files split?

It it using an exact filesize? Before or after the conversion to Unix?
Unix uses a fewer number of characters after the change in line endings.

Or do you want a certain number of lines in each file?


I'm asking the questions because your lines could be cut in the middle of a word if you simply specify a filesize.



Foxi, you beat me to it. The dos/unix aspect makes me think of lines rather than merely blocks of characters. Rather more information required.
5695.

Solve : Batch file "hangs" when loading an .exe file.?

Answer»

First off hi everyone, new here.

I've created a batch file that starts with checking

Code: [Select]if NOT EXIST System\settings.ini (goto firstrun) else (goto start)
This works fine then we go to firstrun:

Code: [Select]:firstrun
start set-server.exe
exit

The command is processed however it hangs for 5-10 seconds before starting set-server.exe.

I have tried /HIGH and using the total folder (ie C:\WhateverDir\set-server.exe)

I must admit when it comes to batch files I am a bit of a NOVICE so please excuse if I've DONE something REALLY stupid.

FYI, set-server.exe is a compiled .ahk script that edits an ini file based on text input. It's only a small script and runs straight away when you click on.

Thank you in advance,

Quote

compiled .ahk script
Tell more about this, please.
Can it be run without being compiled?
Does it? If so, why compile it for a batch program? I've noticed that compiled Autoit scripts (a relative of AutoHotKey) take a few seconds to start up from a batch. It could be they are getting scanned by your antivirus each time. But that does not explain why your compiled AHK script is slower from batch than the prompt.
For the benefit of OTHERS reading this.
AutoHJotKey has been mentioned time and time gain on this forum. Just go to the search box on the top right and enter autohotkey and press enter. Over a hundred posts.
Quote from: Geek-9pm on July 18, 2012, 02:43:45 PM
Tell more about this, please.
Can it be run without being compiled?
Does it? If so, why compile it for a batch program?

Sorry should have elaborated there, it's a basic scripting language that can do basic tasks (run, read / write from ini files) with an easily "coded" GUI. (Not to undersell it, it can do more advanced stuff).

It can be run without being compiled but you have to have Auto Hot Key installed in order for it to operate and I am trying to make this for a few people and it would be easier if it was a self executing file.

I have tried using different .exe (just as a test) and I still get the 5-10 second "hang" with this.

Quote from: Salmon Trout on July 18, 2012, 03:01:25 PM
I've noticed that compiled Autoit scripts (a relative of AutoHotKey) take a few seconds to start up from a batch. It could be they are getting scanned by your antivirus each time. But that does not explain why your compiled AHK script is slower from batch than the prompt.

I think I have figured a work around after reading this. I will make another AHK execution file to do the "if NOT EXIST System\settings.ini (goto firstrun) else (goto start)" then make it either run the set-server.exe or run the original batch file. I think that should do that trick.
5696.

Solve : give information to user after on the computer?

Answer»

i used batch file to delete data from public every week . but i want to inform the users before two days .after the computer on,the first massage on screen SHOW automatically for the user. " pleas back up you data from public folder " how can i do that ? thanks in advance So you want to delete the files, and then 2 days later have them receve a message telling them to back up their data?Task Schedulersure Lemonilla do u have any idea ?


an how to use task scheduler ? Quote from: Mesafint on July 18, 2012, 07:02:44 AM


an how to use task scheduler ?

How to Use Task Schedulertanks Squashman. i used task scheduler to run batch file. and clean public folder, but what i said, how to send a massage for all users using task scheduler. Quote from: Mesafint on July 19, 2012, 01:33:04 AM
tanks Squashman. i used task scheduler to run batch file. and clean public folder, but what i said, how to send a massage for all users using task scheduler.
Since you stated that you run this batch file to clear out thee public folder weekly I have to assume you do it on a specific day of the week. So if you schedule it to run on Friday, have another SCHEDULED task that runs on Wednesday to give them the warning.
5697.

Solve : help a novice - trying to modify hosts file to pad ip with zeros?

Answer»

Trying to pad hosts file so sorting will work properly.



@echo off

SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION

FOR /F "tokens=1,2,3,4,5* delims=. " %%b IN (hosts.txt) do (
set "ip1=00%%b"
set "ip2=00%%c"
set "ip3=00%%d"
set "ip4=00%%e"

echo %%b %%c %%d %%e
echo %ip1:~-3%.%ip2:~-3%.%ip3:~-3%.%ip4:~-3% %%f
)
endlocal

===
hosts.txt
10.25.111.52 aaa
10.25.111.49 bbb
10.25.111.50 ccc
10.25.111.51 ddd


You have DELAYED expansion enabled but you are not USING it. When you need to use delayed expansion you need to reference your variables with exclamation points. Not Percent signs.
Code: [Select]echo !ip1:~-3!.!ip2:~-3!.!ip3:~-3!.!ip4:~-3! %%fQuote

Trying to pad hosts file so sorting will work properly.
Hosts file does not need sorting. Quote from: Geek-9pm on July 17, 2012, 09:56:03 PM
Hosts file does not need sorting.
While that is true it may help the user manage a large hosts file. But I personally would sort the hosts file by the Domain name. Not the IP address. But there are plenty of 3rd party hosts file editors out there and I would bet some of them have the capability to sort the hosts file when it is viewing it.Quote from: Squashman on July 18, 2012, 05:43:25 AM
While that is true it may help the user manage a large hosts file. But I personally would sort the hosts file by the Domain name. Not the IP address. But there are plenty of 3rd party hosts file editors out there and I would bet some of them have the capability to sort the hosts file when it is viewing it.
Exactly!Am I missing something here? If you add 2 zeroes to a decimal byte at the beginning of a dotted quad IP address you clobber it, because Windows interprets numbers with leading zeroes as octal. (0074 octal is 60).

Code: [Select]C:\>ping www.google.com

Pinging www.l.google.com [74.125.132.104] with 32 bytes of data:
Reply from 74.125.132.104: bytes=32 time=33ms TTL=46
Reply from 74.125.132.104: bytes=32 time=31ms TTL=46
Reply from 74.125.132.104: bytes=32 time=60ms TTL=46
Reply from 74.125.132.104: bytes=32 time=38ms TTL=46

Ping statistics for 74.125.132.104:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 31ms, MAXIMUM = 60ms, Average = 40ms

C:\>ping 74.125.132.104

Pinging 74.125.132.104 with 32 bytes of data:
Reply from 74.125.132.104: bytes=32 time=29ms TTL=46
Reply from 74.125.132.104: bytes=32 time=28ms TTL=46
Reply from 74.125.132.104: bytes=32 time=31ms TTL=46
Reply from 74.125.132.104: bytes=32 time=45ms TTL=46

Ping statistics for 74.125.132.104:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 28ms, Maximum = 45ms, Average = 33ms

C:\>ping 0074.125.132.104

Pinging 60.125.132.104 with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 60.125.132.104:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss)

Quote
Am I missing something here? If you add 2 zeroes to a decimal byte at the beginning of a dotted quad IP address you clobber it, because Windows interprets numbers with leading zeroes as octal. (0074 octal is 60).

Probably true, so why not use spaces for FIRST octet? This little piece of doggerel will show the mechanics of doing this, but as mentioned there is no reason to sort the Hosts file.

Code: [Select]@echo off
setlocal enabledelayedexpansion

if exist sorted del sorted
if exist unsorted del unsorted

for /f "tokens=1-2*" %%i in (c:\windows\system32\drivers\etc\hosts) do (
for /f "tokens=1-4 delims=." %%r in ("%%i") do (
set "ip1= %%r"
set "ip2=00%%s"
set "ip3=00%%t"
set "ip4=00%%u"

echo !ip1:~-3!.!ip2:~-3!.!ip3:~-3!.!ip4:~-3! %%j >> unsorted
)
)

sort /+1 unsorted /o sorted

Be patient. Code runs at the speed of continental DRIFT.

Note: if you change the sort key offset, you can sort on the domain name.Here is a discussion of this for UNIX
http://www.madboa.com/geek/sort-addr/
The UNIX sort has more options that the Windows sort.
Sorting IP address presents a challenge.This works here and handles lines with rems. The delims is set to dotTABspace and the TAB is required because Windows 7 at least converts hosts space delimiters to TABS.

Input file is hosts.txt and output file is HOSTS

Code: [Select]@echo off
SETLOCAL ENABLEDELAYEDEXPANSION

del *.tmp 2>nul


FOR /F "tokens=1,2,3,4,* delims=. " %%a IN (hosts.txt) do (
set a=%%a
set ip1=
set ip2=
set ip3=
set ip4=

if not "!a:~0,1!"=="#" (

set "ip1=00%%a"
set "ip2=00%%b"
set "ip3=00%%c"
set "ip4=00%%d"

echo !ip1:~-3!.!ip2:~-3!.!ip3:~-3!.!ip4:~-3!

>>file.tmp echo !ip1:~-3!.!ip2:~-3!.!ip3:~-3!.!ip4:~-3! %%a.%%b.%%c.%%d %%e
) else (
>>file3.tmp echo %%a %%b %%c %%d %%e
)
)

sort <file.tmp >file2.tmp

FOR /F "tokens=1,*" %%b IN (file2.tmp) do (
>>file4.tmp echo %%c
)
copy /b file3.tmp + file4.tmp hosts >nul
del *.tmp
pause
endlocalModification to also cater for source files that do not contain any comment lines.

Code: [Select]@echo off
SETLOCAL ENABLEDELAYEDEXPANSION

del *.tmp 2>nul


FOR /F "tokens=1,2,3,4,* delims=. " %%a IN (hosts.txt) do (
set a=%%a
set ip1=
set ip2=
set ip3=
set ip4=

if not "!a:~0,1!"=="#" (

set "ip1=00%%a"
set "ip2=00%%b"
set "ip3=00%%c"
set "ip4=00%%d"

echo !ip1:~-3!.!ip2:~-3!.!ip3:~-3!.!ip4:~-3!

>>file.tmp echo !ip1:~-3!.!ip2:~-3!.!ip3:~-3!.!ip4:~-3! %%a.%%b.%%c.%%d %%e
) else (
>>file3.tmp echo %%a %%b %%c %%d %%e
)
)

sort <file.tmp >file2.tmp

FOR /F "tokens=1,*" %%b IN (file2.tmp) do (
>>file4.tmp echo %%c
)

if exist file3.tmp (
copy /b file3.tmp + file4.tmp hosts >nul
) else (
move file4.tmp hosts >nul
)


del *.tmp
pause
endlocal
5698.

Solve : Batch File copying text from one file to another cuts off at first space?

Answer»

Hi. I have a batch file to remove the last line of my .TXT file. In this case it copies all rows (except the last one) from d177920101id.txt
and into docinfo.txt

It copies the lines great, but each line is cut off at the first space.

So in d177920101id.txt I have the lines
BIG|CONSTRUCTION|INC
HANSEN|TOWING AND REPAIR|INC
EOF 2

In docinfo.txt I end up with
BIG|CONSTRUCTION|INC
HANSEN|TOWING

Any idea how I can change my batch file to copy the entire lines including the spaces?

Code: [SELECT]SETLOCAL ENABLEDELAYEDEXPANSION

rem Count the lines in file
set /a count=-1
for /F %%a in (d177920101id.txt) DO set /a count=!count!+1

rem Create empty temp file
copy /y NUL tempfile.txt >NUL

rem Copy all but last line
for /F %%a in (d177920101id.txt) DO (
IF /I !count! GTR 0 (
echo %%a >> tempfile.txt
set /a count=!count!-1
)
)

rem overwrite original file, DELETE temp file
copy /y tempfile.txt docinfo.txt >NUL
del tempfile.txt
Change: 'for /F %%a in ...' to 'for /F "delims=" %%a in ...'
Quote from: bmacbmac on July 19, 2012, 02:29:39 PM

Hi. I have a batch file to remove the last line of my .txt file. In this case it copies all rows (except the last one) from d177920101id.txt
and into docinfo.txt

It copies the lines great, but each line is cut off at the first space.

So in d177920101id.txt I have the lines
BIG|CONSTRUCTION|INC
HANSEN|TOWING AND REPAIR|INC
EOF 2

In docinfo.txt I end up with
BIG|CONSTRUCTION|INC
HANSEN|TOWING

Any idea how I can change my batch file to copy the entire lines including the spaces?

Code: [Select]SETLOCAL ENABLEDELAYEDEXPANSION

rem Count the lines in file
set /a count=-1
for /F %%a in (d177920101id.txt) DO set /a count=!count!+1

rem Create empty temp file
copy /y NUL tempfile.txt >NUL

rem Copy all but last line
for /F %%a in (d177920101id.txt) DO (
IF /I !count! GTR 0 (
echo %%a >> tempfile.txt
set /a count=!count!-1
)
)

rem overwrite original file, delete temp file
copy /y tempfile.txt docinfo.txt >NUL
del tempfile.txt
If you read the help file for the FOR command you would have read this.
Code: [Select]delims=xxx - specifies a delimiter set. This replaces the
default delimiter set of space and tab.Thank you, that was extremely helpful. Adding "delims=" worked perfectly!
5699.

Solve : Date & Time naming of log files?

Answer»

I have several time and date routines too.

There's VBS, WMIC, Powershell, and even an Ascii Binary


Code: [Select] :: date time using WSH
:: datetime.bat V4
::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::
:: This USES Windows Scripting Host to set variables
:: to the current date/time/day/day_number
:: for Win9x/ME/NT/W2K/XP etc
:: Thanks go to Todd Vargo for his scripting
::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
set TmpFile="%temp%.\tmp.vbs"
echo> %TmpFile% n=Now
echo>>%TmpFile% With WScript
echo>>%TmpFile% .Echo "set year=" + CStr(Year(n))
echo>>%TmpFile% .Echo "set yr=" + Right(Year(n),2)
echo>>%TmpFile% .Echo "set month="+ Right(100+Month(n),2)
echo>>%TmpFile% .Echo "set day=" + Right(100+Day(n),2)
echo>>%TmpFile% .Echo "set hour=" + Right(100+Hour(n),2)
echo>>%TmpFile% .Echo "set min=" + Right(100+Minute(n),2)
echo>>%TmpFile% .Echo "set sec=" + Right(100+Second(n),2)
echo>>%TmpFile% .Echo "set dow=" + WeekDayName(Weekday(n),1)
echo>>%TmpFile% .Echo "set dow2=" + WeekDayName(Weekday(n))
echo>>%TmpFile% .Echo "set iso=" + CStr(1 + Int(n-2) mod 7)
echo>>%TmpFile% .Echo "set iso2=" + CStr(Weekday(n,2))
echo>>%TmpFile% End With
cscript //nologo "%temp%.\tmp.vbs" > "%temp%.\tmp.bat"
call "%temp%.\tmp.bat"
del "%temp%.\tmp.bat"
del %TmpFile%
set TmpFile=
set stamp=%year%-%month%-%day%_%hour%.%min%.%sec%
::
echo The year (YYyy) is "%year%"
echo The year (yy) is "%yr%"
echo The month is "%month%"
echo The day (%dow%) is "%day%"
echo The full weekday name is "%dow2%"
echo.
echo ISO 8601 Day-Of-Week number is "%iso%"
echo.
echo The hour is "%hour%"
echo The minute is "%min%"
echo The second is "%sec%"
echo.
::
echo The date and time stamp is "%stamp%"
echo.
echo time (hhmmss) (%hour%%min%%sec%)
echo.
echo date A (yyyymmdd) (%year%%month%%day%)
echo date B (mmddyyyy) (%month%%day%%year%)
echo date C (ddmmyyyy) (%day%%month%%year%)
echo.
echo date D [yymmdd] [%yr%%month%%day%]
echo date E [mmddyy] [%month%%day%%yr%]
echo date F [ddmmyy] [%day%%month%%yr%]
:: datetime.bat
::::::::::::::::::::::::::::::::::::::::::::::::::::::::


echo.
pause
echo.


:: date time using WMIC
:: XP Pro and higher
@echo off
for /f "delims=" %%a in ('Wmic Path Win32_LocalTime Get /value ^|Find "="') do (
for /f "tokens=1,* delims==" %%b in ('cmd /c echo %%a') do set "%%b=00%%c")
set DayOfWeek=%DayOfWeek:~2%
set Quarter=%Quarter:~2%
set WeekInMonth=%WeekInMonth:~2%
set Day=%Day:~-2%
set Hour=%Hour:~-2%
set Minute=%Minute:~-2%
set Month=%Month:~-2%
set Second=%Second:~-2%
set Yr=%Year:~4%
set Year=%Year:~2%
set stamp=%year%-%month%-%day%_%hour%-%minute%-%second%
echo %%stamp%% is set to %stamp% (yyyy-mm-dd_hh-mm-ss)

echo.
pause
echo.

:: timestamp YYYYMMDD_HHMMSS
:: date time using WMIC
:: XP Pro and higher
@echo off
for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set dt=%%a
echo %dt:~0,8%_%dt:~8,6%

echo.
pause
echo.

:: timestamp YYYY-MM-DD_HH-MM-SS
:: date time using WMIC
:: XP Pro and higher
@echo off
for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set dt=%%a
echo %dt:~0,4%-%dt:~4,2%-%dt:~6,2%_%dt:~8,2%-%dt:~10,2%-%dt:~12,2%

echo.
pause
echo.

:: date time with Powershell
@echo off
for /f "tokens=1-6 delims=-" %%a in (
'powershell get-date -uformat "%%Y-%%m-%%d-%%H-%%M-%%S"'
) do (
set year=%%a&set mon=%%b&set day=%%c
set hour=%%d&set min=%%e&set sec=%%f
)
echo %year%-%mon%-%day% %hour%:%min%:%sec%

echo.
pause
echo.

:: date time using an ascii binary
@echo off
:: Code by Herbert Kleebauer
echo [emailprotected]`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=>d_t.com
echo 0DxFP,0Xx.t0P,[emailprotected]$?PIyU WwX0GwUY Wv;ovBX2Gv0ExGIuht6>>d_t.com
echo LisqMz`[emailprotected]`[emailprotected]?ogBgGG}G?j_egoNOG?w?`gBLksqgG`w?WgBgG>>d_t.com
echo G}[emailprotected][emailprotected]`LrFuBLyt~vuco{@LuKooD?BFHqrIcP>>d_t.com
echo _sdDxb1T??=?rILO_sdDqx1T??=?rILO_sdDnl1T??=?rILO_sdD`c1T??>>d_t.com
echo =?rILO_sdDgg1T??=?rILO_sdDll1T??=?rILO_sdDrr1T??=??IL?0xxx>>d_t.com
d_t.com>d_t.bat
call d_t.bat
del d_t.com
del d_t.bat
echo century: %_cy%
echo year: %_yr%
echo month: %_mo%
echo day: %_da%
echo hour: %_hh%
echo minute: %_mm%
echo second: %_ss%

echo.
pause
echo.
Quote from: Salmon Trout on July 22, 2012, 01:17:44 AM

You're thinking of Visual Studio.

Well, VB6/VBA, as OPPOSED to VBScript, which doesn't have the Format Function apparently.
5700.

Solve : batch file to replace string?

Answer»

i working on a script that detect weird date in the FILE and replace them with yesterday date. here the raw data assuming yesterday date
is 2012-07-19

rawfile.txt
Code: [Select]AAAAAAAA 0001-01-01-00.00.00.000000 Change Password RSO part
BBBBBBBB 0001-01-01-00.00.00.000000 Change Password RSO part
CCCCCCC 0001-01-01-00.00.00.000000 Set Nbr try of password
DDDDDDD 2012-07-19-09.44.25.634000 Change Password

result.txt
Code: [Select]AAAAAAAA 2012-07-19-00.00.00.000000 Change Password RSO part
BBBBBBBB 2012-07-19-00.00.00.000000 Change Password RSO part
CCCCCCC 2012-07-19-00.00.00.000000 Set Nbr try of password
DDDDDDD 2012-07-19-09.44.25.634000 Change Password



I am new to dos batch file. However, COME out a basic strategy which i will first loop through each line to detect this scenario (0001-01-01) in fact there is only this scenario I then replace the date to yesterday.

i have try to write the code as follow
Code: [Select]REM Code to Find YEsterday's date
set yyyy=

set $tok=1-3
for /f "tokens=1 delims=.:/-, " %%u in ('date /t') do set $d1=%%u
if "%$d1:~0,1%" GTR "9" set $tok=2-4
for /f "tokens=%$tok% delims=.:/-, " %%u in ('date /t') do (
for /f "skip=1 tokens=2-4 delims=/-,()." %%x in ('echo.^|date') do (
set %%x=%%u
set %%y=%%v
set %%z=%%w
set $d1=
set $tok=))

if "%yyyy%"=="" set yyyy=%yy%
if /I %yyyy% LSS 100 set /A yyyy=2000 + 1%yyyy% - 100

set CurDate=%mm%/%dd%/%yyyy%
set dayCnt=%1

if "%dayCnt%"=="" set dayCnt=1

REM Substract your days here
set /A dd=1%dd% - 100 - %dayCnt%
set /A mm=1%mm% - 100

:CHKDAY
if /I %dd% GTR 0 goto DONE
set /A mm=%mm% - 1
if /I %mm% GTR 0 goto ADJUSTDAY
set /A mm=12
set /A yyyy=%yyyy% - 1

:ADJUSTDAY
if %mm%==1 goto SET31
if %mm%==2 goto LEAPCHK
if %mm%==3 goto SET31
if %mm%==4 goto SET30
if %mm%==5 goto SET31
if %mm%==6 goto SET30
if %mm%==7 goto SET31
if %mm%==8 goto SET31
if %mm%==9 goto SET30
if %mm%==10 goto SET31
if %mm%==11 goto SET30
REM ** Month 12 falls through

:SET31
set /A dd=31 + %dd%
goto CHKDAY

:SET30
set /A dd=30 + %dd%
goto CHKDAY

:LEAPCHK
set /A tt=%yyyy% %% 4
if not %tt%==0 goto SET28
set /A tt=%yyyy% %% 100
if not %tt%==0 goto SET29
set /A tt=%yyyy% %% 400
if %tt%==0 goto SET29

:SET28
set /A dd=28 + %dd%
goto CHKDAY

:SET29
set /A dd=29 + %dd%
goto CHKDAY

CALL :process <..\input.txt>> ..\output.txt

:process
set line=
if "!line:~12,22!" neq "0001-01-01" goto process
## for /F between line:~12,22 do (
------------------------------------------------
this part onward i not very sure already.
intend to do a for loop each line replace "0001-01-01" to %yyyy%-%mm%-%dd%


)


i wonder how to continue the code to make it work.. would appreciate if anyone can help!!This works here with rawfile.txt

Code: [Select]@echo off
setlocal EnableExtensions EnableDelayedExpansion
call :yesterday today -1
for /f "delims=" %%a in (rawfile.txt) do (
set "val=%%a"
if "!val:~12,10!"=="0001-01-01" (
>> newfile.txt echo !val:~0,12!%day%!val:~22!
) else (
>> newfile.txt echo %%a
)
)
pause
GOTO:EOF
:yesterday
:: Date foward & backward
@echo off
:: from code by Phil Robyn
setlocal
if [%1]==[] (
echo to get todays date use
echo call "%~n0" today 0
echo.
echo to get yesterdays date use
echo call "%~n0" today -1
echo.
echo to get the date 25 days ago:
echo call "%~n0" today -25
echo.
echo to get the date 1250 days in the future
echo call "%~n0" today +1250
goto :EOF)

set date1=%1
set qty=%2
if /i "%date1%" EQU "TODAY" (
set date1=now
) else (
set date1="%date1%"
)
echo >"%temp%\%~n0.vbs" s=DateAdd("d",%qty%,%date1%)
echo>>"%temp%\%~n0.vbs" WScript.Echo year(s)^&_
echo>>"%temp%\%~n0.vbs" right(100+month(s),2)^&_
echo>>"%temp%\%~n0.vbs" right(100+day(s),2)
for /f %%a in (
'cscript //nologo "%temp%\%~n0.vbs"') do set result=%%a
del "%temp%\%~n0.vbs"
endlocal& set day=%result:~0,4%-%result:~4,2%-%result:~6,2%
:: echo %%day%% is set to "%day%" (without the quotes)HI Foxidrive,

thank you for your help. the script work nice.!

Btw, i want to loop through the folder for each file inside folder do the change date code.

so i try to do this but failed.

Code: [Select]cd ..\input ##(to the folder that has all the data)



for %%f in (*.txt) do (

echo "%%~nf"
"D:\something\deployment code\change_date" .\"%%~nf".txt
)

Code: [Select]@echo off
setlocal EnableExtensions EnableDelayedExpansion
call :yesterday today -1
for /f "delims=" %%a in (%1) do ( ## (which i try to pass the file from the folder to this line, i thought is to loop through.. )
set "val=%%a"
if "!val:~12,10!"=="0001-01-01" (
>> newfile.txt echo !val:~0,12!%day%!val:~22!
) else (
>> newfile.txt echo %%a
)
)
however, it doesnt work. would you be able to enlighten me,
thanks!!!hi,

thanks,.
i figure it out to do already

Code: [Select]@echo off
setlocal EnableExtensions EnableDelayedExpansion
call :yesterday today -1
for /f "delims=" %%a in ('type %1') do (
set "val=%%a"
if "!val:~12,10!"=="0001-01-01" (
>> ..\temp1\%1_date.txt echo !val:~0,12!%day%!val:~22!
) else (
>> ..\temp1\%1_date.txt echo %%a
)
)