Hopefully this will help others. I have been going around in circles trying to get a simple copy.bat file to run in win 7, UAC is the culprit. I found a thread that said if you make a short-cut to the bat file and then run as administrator it will run OK. This is only half true, I have a copy.bat that just copies a db file to a backup drive if this is placed on the desktop it will not run, I tried it in docs (with a shortcut to the desktop and run as admin) and it still would not run, when I placed it in the same directory as the db file and then created a short-cut on the desktop with “run as administrator” it worked.
![]() |
There are isolated problems with current patches, but they are well-known and documented on this site. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
batch files and win 7
Home » Forums » AskWoody support » Windows » Windows 7 » Questions: Windows 7 » batch files and win 7
- This topic has 9 replies, 3 voices, and was last updated 15 years, 6 months ago.
Viewing 0 reply threadsAuthorReplies-
WSStuartR
AskWoody LoungerNovember 22, 2009 at 6:16 am #1186362Hopefully this will help others. I have been going around in circles trying to get a simple copy.bat file to run in win 7, UAC is the culprit. I found a thread that said if you make a short-cut to the bat file and then run as administrator it will run OK. This is only half true, I have a copy.bat that just copies a db file to a backup drive if this is placed on the desktop it will not run, I tried it in docs (with a shortcut to the desktop and run as admin) and it still would not run, when I placed it in the same directory as the db file and then created a short-cut on the desktop with “run as administrator” it worked.
I have a similar problem with a BAT file that I want to run from my Startup folder. This BAT file shares a drive that doesn’t exist at boot time. I have two problems with this.
- [*]The syntax IF EXIST D:NUL no longer seems to work, so I can’t check if the drive exists[*]I can run the shortcut manually (and accept the UAC warning) but it does nothing at all in the startup folder
-
WSgws
AskWoody LoungerNovember 22, 2009 at 7:07 am #1186365I have a similar problem with a BAT file that I want to run from my Startup folder. This BAT file shares a drive that doesn’t exist at boot time. I have two problems with this.
- [*]The syntax IF EXIST D:NUL no longer seems to work, so I can’t check if the drive exists[*]I can run the shortcut manually (and accept the UAC warning) but it does nothing at all in the startup folder
Hi Stuart, I just tried as an experiment my copy.bat file in the start up folder and it worked, I created a shortcut to my file copy.bat and placed it in C:usersgwsAppDataRoamingMicrosoftWindowsStartMenuPrograms gave it “Run as Administrator” rights and rebooted my computer and it created a copy in my backup folder. I dont know enough about Batch file scripting to help you with your script but I suspect others can. Good luck.gws.
-
WSStuartR
AskWoody LoungerNovember 22, 2009 at 5:58 pm #1186414Hi Stuart, I just tried as an experiment my copy.bat file in the start up folder and it worked, I created a shortcut to my file copy.bat and placed it in C:usersgwsAppDataRoamingMicrosoftWindowsStartMenuPrograms gave it “Run as Administrator” rights and rebooted my computer and it created a copy in my backup folder. I dont know enough about Batch file scripting to help you with your script but I suspect others can. Good luck.gws.
Thanks for that.
The folder in which I put a shortcut to my BAT file was c:Program DataMicrosoftWindowsStart MenuProgramsStartup
I can run the program by clicking on the Start Menu and navigating to the shortcut, but it doesn’t run when I log in.
-
-
BATcher
AskWoody_MVPNovember 23, 2009 at 6:29 am #1186439The syntax IF EXIST D:NUL no longer seems to work, so I can’t check if the drive exists
That NUL check has always produced anomalous results in various versions of Windows, especially when used with short v. long filenames, path in quotes v. path without quotes, or (it is suggested) FAT32 files v. NTFS files.
You could try
Code:FSUTIL FSINFO DRIVETYPE x:
which for an absent drive letter gives
Code:x: - No such Root Directory
but the errorlevel for all drive types comes out as zero… And you need to be an Administrator to run it!
BATcher
Plethora means a lot to me. -
BATcher
AskWoody_MVPNovember 23, 2009 at 6:38 am #1186441Stuart
I’ve just tried
Code:IF EXIST x:NUL ECHO x: EXISTS
for both C: (boot drive) and Q: (non-mapped drive) in both XP and Windows 7, and got the expected results – you you may need to look further…
I’m just investigating running BATch files “elevated” in Windows 7.
BATcher
Plethora means a lot to me. -
WSStuartR
AskWoody LoungerNovember 23, 2009 at 12:08 pm #1186477Stuart
I’ve just tried
Code:IF EXIST x:NUL ECHO x: EXISTS
for both C: (boot drive) and Q: (non-mapped drive) in both XP and Windows 7, and got the expected results – you you may need to look further…
I’m just investigating running BATch files “elevated” in Windows 7.
That is very helpful. Did you test it with a drive that doesn’t exist? My problem was that it always returned success even if the drive didn’t exist.
-
BATcher
AskWoody_MVPNovember 23, 2009 at 12:11 pm #1186478 -
WSStuartR
AskWoody LoungerNovember 23, 2009 at 1:08 pm #1186481I wasn’t sufficiently explicit – Q: doesn’t exists, not even as a mapped drive, on my PC!
Strange, the syntax I was using was
IF EXIST V:NUL GOTO CREATED
ECHO do something about it
PAUSE
:CREATEDThis is now working correctly, but I swear it was always going straight to the CREATED label when I tested it last week!
-
BATcher
AskWoody_MVP
-
-
-
-
Viewing 0 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Office gets current release
by
Susan Bradley
42 minutes ago -
FBI: Still Using One of These Old Routers? It’s Vulnerable to Hackers
by
Alex5723
2 hours, 19 minutes ago -
Windows AI Local Only no NPU required!
by
RetiredGeek
1 hour, 15 minutes ago -
Stop the OneDrive defaults
by
CWBillow
3 hours, 8 minutes ago -
Windows 11 Insider Preview build 27868 released to Canary
by
joep517
13 hours, 4 minutes ago -
X Suspends Encrypted DMs
by
Alex5723
15 hours, 16 minutes ago -
WSJ : My Robot and Me AI generated movie
by
Alex5723
15 hours, 34 minutes ago -
Botnet hacks 9,000+ ASUS routers to add persistent SSH backdoor
by
Alex5723
16 hours, 11 minutes ago -
OpenAI model sabotages shutdown code
by
Cybertooth
16 hours, 48 minutes ago -
Backup and access old e-mails after company e-mail address is terminated
by
M W Leijendekker
4 hours, 58 minutes ago -
Enabling Secureboot
by
ITguy
11 hours, 58 minutes ago -
Windows hosting exposes additional bugs
by
Susan Bradley
1 day ago -
No more rounded corners??
by
CWBillow
20 hours, 31 minutes ago -
Android 15 and IPV6
by
Win7and10
10 hours, 16 minutes ago -
KB5058405 might fail to install with recovery error 0xc0000098 in ACPI.sys
by
Susan Bradley
1 day, 13 hours ago -
T-Mobile’s T-Life App has a “Screen Recording Tool” Turned on
by
Alex5723
1 day, 15 hours ago -
Windows 11 Insider Preview Build 26100.4202 (24H2) released to Release Preview
by
joep517
1 day, 10 hours ago -
Windows Update orchestration platform to update all software
by
Alex5723
1 day, 23 hours ago -
May preview updates
by
Susan Bradley
1 day, 10 hours ago -
Microsoft releases KB5061977 Windows 11 24H2, Server 2025 emergency out of band
by
Alex5723
1 day, 2 hours ago -
Just got this pop-up page while browsing
by
Alex5723
1 day, 15 hours ago -
KB5058379 / KB 5061768 Failures
by
crown
1 day, 12 hours ago -
Windows 10 23H2 Good to Update to ?
by
jkitc
14 hours, 31 minutes ago -
At last – installation of 24H2
by
Botswana12
2 days, 14 hours ago -
MS-DEFCON 4: As good as it gets
by
Susan Bradley
11 hours, 18 minutes ago -
RyTuneX optimize Windows 10/11 tool
by
Alex5723
3 days, 2 hours ago -
Can I just update from Win11 22H2 to 23H2?
by
Dave Easley
1 day, 1 hour ago -
Limited account permission error related to Windows Update
by
gtd12345
3 days, 16 hours ago -
Another test post
by
gtd12345
3 days, 16 hours ago -
Connect to someone else computer
by
wadeer
3 days, 10 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.