China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-12 11:00
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] Randomly generate a file and run it View 1,480 Replies 10
Original Poster Posted 2010-04-08 04:08 ·  中国 云南 昆明 电信
初级用户
Credits 52
Posts 30
Joined 2007-02-13 02:30
19-year member
UID 79344
Gender Male
Status Offline
Question for the experts. Can someone help me write a batch file? VBS would also be fine. What I mean is: randomly generate a file, and open that file or run that file. Thanks. For example: if the randomly generated file is 1.exe, then run 1.exe
If the randomly generated file is 235.exe, then run 235.exe
Floor 2 Posted 2010-04-08 11:22 ·  IANA 局域网IP(Private-Use)
新手上路
Credits 6
Posts 7
Joined 2010-02-26 16:39
16-year member
UID 161245
Gender Male
Status Offline
Looks like you're trying to do some damage
Floor 3 Posted 2010-04-08 12:25 ·  中国 吉林 延边朝鲜族自治州 延吉市 电信
银牌会员
★★★
正在学习中的菜鸟...
Credits 1,039
Posts 897
Joined 2009-03-01 15:34
17-year member
UID 140302
Gender Male
From 在地狱中仰望天堂
Status Offline
Here's an example for you:
@echo off
set r=%random%.txt
echo.测试>%r%
start %r%

The filename is made up of random numbers.

[ Last edited by Hanyeguxing on 2010-4-10 at 16:38 ]
Floor 4 Posted 2010-04-09 14:47 ·  中国 陕西 咸阳 电信
初级用户
★★
Credits 128
Posts 122
Joined 2009-09-21 06:24
16-year member
UID 152378
Gender Male
Status Offline
For the randomly generated exe file you want, how many different kinds of code would need to be written?
Floor 5 Posted 2010-04-10 11:12 ·  中国 云南 昆明 电信
初级用户
Credits 52
Posts 30
Joined 2007-02-13 02:30
19-year member
UID 79344
Gender Male
Status Offline
Thanks, Hanyeguxing
for your code. What I want is to make a BMP image myself, say 1.BMP, then copy it to the system folder under a random new name, and import that randomly renamed name into the registry. How should that be written?
Floor 6 Posted 2010-04-10 13:59 ·  中国 重庆 电信
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Why didn't you say so earlier? Isn't this just wasting Hanyeguxing's time and enthusiasm?
Floor 7 Posted 2010-04-10 14:25 ·  中国 云南 昆明 电信
初级用户
Credits 52
Posts 30
Joined 2007-02-13 02:30
19-year member
UID 79344
Gender Male
Status Offline
Mr. Moderator, could you please help me write one? Thanks. Renaming it with a time-based name would also be fine.
Floor 8 Posted 2010-04-10 15:50 ·  中国 吉林 延边朝鲜族自治州 延吉市 电信
银牌会员
★★★
正在学习中的菜鸟...
Credits 1,039
Posts 897
Joined 2009-03-01 15:34
17-year member
UID 140302
Gender Male
From 在地狱中仰望天堂
Status Offline
Originally posted by yatv2000 at 2010-4-10 11:12:
Thanks, Hanyeguxing
for your code. What I want is to make a BMP image myself, say 1.BMP, then copy it to the system folder under a random new name, and import that randomly renamed name into the registry. How should that be written?

1,What requirements are there for the random name?
2,Which system folder?
3,What location in the registry?
4,What is the purpose of the whole operation?
Floor 9 Posted 2010-04-10 16:16 ·  中国 云南 昆明 电信
初级用户
Credits 52
Posts 30
Joined 2007-02-13 02:30
19-year member
UID 79344
Gender Male
Status Offline
Floor 10 Posted 2010-04-10 16:51 ·  中国 吉林 延边朝鲜族自治州 延吉市 电信
银牌会员
★★★
正在学习中的菜鸟...
Credits 1,039
Posts 897
Joined 2009-03-01 15:34
17-year member
UID 140302
Gender Male
From 在地狱中仰望天堂
Status Offline
@echo off
:s:r is the full image name
set "r=123.bmp"
set "s=%WINDIR%\system32\%random%.bmp"
if exist "%s%" goto s
copy "%r%" "%s%"
reg add "HKU\.DEFAULT\Control Panel\Desktop" /v Wallpaper /t REG_SZ /d "%s%" /f >nul
del %0


[ Last edited by Hanyeguxing on 2010-4-10 at 16:54 ]
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
yatv2000 +2 2010-04-13 05:39
Floor 11 Posted 2010-04-13 05:39 ·  中国 云南 昆明 电信
初级用户
Credits 52
Posts 30
Joined 2007-02-13 02:30
19-year member
UID 79344
Gender Male
Status Offline
Originally posted by Hanyeguxing at 2010-4-10 04:51 PM:
@echo off
:s:r为图片完整名称
set "r=123.bmp"
set "s=%WINDIR%\system32\%random%.bmp"
if exist "%s%" goto s
copy "%r%" "%s%"
reg a ...


Thanks to Hanyeguxing for writing this code for me. The code you wrote completely solves the problem. My sincere thanks to you!
Forum Jump: