Search found 187 matches

by Fawers
25 Apr 2012 07:43
Forum: DOS Batch Forum
Topic: Check if the file was run as an admin?
Replies: 9
Views: 3680

Re: Check if the file was run as an admin?

So this is really a definitive way of proving admin permissions of the user. If it is executed in Win7 by a normal user and 'run as administrator' then it works too. @echo off net localgroup administrators 2>nul |find "%username%">nul || ( echo not admin, go away or I shall taunt you a se...
by Fawers
25 Apr 2012 04:05
Forum: DOS Batch Forum
Topic: How do I assign the value of one variable to another variabl
Replies: 4
Views: 5653

Re: How do I assign the value of one variable to another var

SET filename=%xfileName% DOES overwrite %filename%. If you want %xfilename% to be part of %filename%, then you should do something like

Code: Select all

set filename=%filename% %xfilename%

or

Code: Select all

set filename=%xfilename% %filename%
.
by Fawers
23 Apr 2012 10:33
Forum: DOS Batch Forum
Topic: Cannot Exit exactly when i want to
Replies: 4
Views: 2338

Re: Cannot Exit exactly when i want to

Squashman's info is right.
exit /b works for your call command. I think it's okay to say that the /b switch acts as a "function breaker."
Any exit /b inside a called function will exit the function, and not the whole batch file.
by Fawers
22 Apr 2012 11:18
Forum: DOS Batch Forum
Topic: help with playlist creator
Replies: 16
Views: 4091

Re: help with playlist creator

In this part: for /f "delims=" %%p in ('dir /b /on *.asf *.avi *.divx *.flv *.m2ts *.mp4 *.mpg *.ogm *.wmv *.mp3 *.wma *.mkv *.flac *TS.ifo') do ( (echo %%~Fp)>>"%%~nb.m3u" Try changing (echo %%~Fp )>>"%%~nb.m3u" to (echo %%~Nb\%%~NXp )>>"%%~nb.m3u"
by Fawers
21 Apr 2012 22:13
Forum: DOS Batch Forum
Topic: help with playlist creator
Replies: 16
Views: 4091

Re: help with playlist creator

Ok. We can do something inside the FOR loops. Do you need it in a hurry?
by Fawers
21 Apr 2012 16:19
Forum: DOS Batch Forum
Topic: Check if the file was run as an admin?
Replies: 9
Views: 3680

Re: Check if the file was run as an admin?

foxidrive wrote:This might work too.

Code: Select all

@echo off
md "%windir%\a-test" 2>nul&& (echo You're admin & rd "%windir%\a-test") || echo Not admin


That's a faster, more secure way, I think.
by Fawers
21 Apr 2012 16:16
Forum: DOS Batch Forum
Topic: help with playlist creator
Replies: 16
Views: 4091

Re: help with playlist creator

Actually, not only is it tested, but also I began using it. It's a very interesting idea that he's had.
by Fawers
21 Apr 2012 15:25
Forum: DOS Batch Forum
Topic: help with playlist creator
Replies: 16
Views: 4091

Re: help with playlist creator

You're right. The 2nd script won't output anything to any file. I'm trying to figure how to make it output to a file out (since I liked the idea). And, yes, there is a way. It is recommended, however, that you delete all the .M3U files created before, because I use the ">>" redirection met...
by Fawers
21 Apr 2012 13:31
Forum: DOS Batch Forum
Topic: help with playlist creator
Replies: 16
Views: 4091

Re: help with playlist creator

I've posted 2 codes. They are untested, so I'd like you to tell me whether they work or not.

Hope it will do the job. :wink:
by Fawers
21 Apr 2012 13:12
Forum: DOS Batch Forum
Topic: help with playlist creator
Replies: 16
Views: 4091

Re: help with playlist creator

I see. I'm working on it. 1st Edit: Here's the first method (if you don't mind having all file types in the same file). (Untested) @echo off setlocal :START set "playlist=playlist.m3u" for /f "delims=" %%a in ('dir /b /ad') do ( pushd %%a for /f "delims=" %%b in ('dir /...
by Fawers
21 Apr 2012 13:05
Forum: DOS Batch Forum
Topic: Check if the file was run as an admin?
Replies: 9
Views: 3680

Re: Check if the file was run as an admin?

On Windows 7, I know that the AT command can only be run with administrative privileges. It shows an error message when they [adm privileges] are not activated. What you could do is, @echo off (at 2>nul)&&goto :YourCode echo This program must be run with administrative privileges. echo Pleas...
by Fawers
21 Apr 2012 12:54
Forum: DOS Batch Forum
Topic: help with playlist creator
Replies: 16
Views: 4091

Re: help with playlist creator

Um, I understood what you want - and I am working on it already -, but I didn't really understand your code - which means I'm not working based on it. I tested it a couple of times, and %folder% is always equal to %currentfolder%. Besides, you could have used PUSHD .. instead of SET currentfolder=&q...
by Fawers
20 Apr 2012 17:24
Forum: DOS Batch Forum
Topic: Variable space
Replies: 2
Views: 1063

Re: Variable space

Code: Select all

if /i "%command%" == "net user shutdown" goto SHUTDOWN

Edit: You might want to use the /i switch. It makes IF statements (and lots of other commands) case insensitive.
by Fawers
16 Apr 2012 16:23
Forum: DOS Batch Forum
Topic: read file names and call bat files [SOLVED]
Replies: 5
Views: 1715

Re: newbie needs help - read file names and call bat files

Squashman wrote:And if you are using Windows Vista or 7 you could substitute the PING commands with the TIMEOUT command.

Didn't know of that one. Will try it on my 7.
by Fawers
16 Apr 2012 16:19
Forum: DOS Batch Forum
Topic: Using a batch to change the File Date (recursively?)
Replies: 20
Views: 9385

Re: Using a batch to change the File Date (recursively?)

Squashman wrote:

Code: Select all

for /F "tokens=*" %%G in ('dir /b /s /ad H:') do copy  "%%G\*.*"  /B  +  ,,  /Y


What do those 2 commas next to /Y do, exactly? They are confusing me.