hey everyone im a bit of a noob with programing because im only 16 so can you please explain your reply simply.

im trying to make a batch file that asks for a password and opens a file and if the password is wrong displays a message i know how to do this with a .vbs file (like the one you type in notepad not like visual basic 6). i will put the .vbs code up and could some one please show me how to put into cmd lanugage

x = inputbox ("type in password")

if x = "mypassword" then
set x = createobject("wscript.shell")
x.run "file i want to open"

else

z = msgbox("wrong",0,"Error")

end if

Recommended Answers

All 5 Replies

use this in batch file

@echo off
set /p pass= What is Password?

if %pass% ==yourpassword start c:\passwordprotected.txt

thanks you are my hero :)

small problem im trying to use the %userprofile% command for the file location ( %userprofile%\Desktop\Folder) but it wont open the full location it just opens the %userprofile% part what am I doing wrong???

Check out this thread about "UserProfile".

You can also use this to get a user's Desktop directory.

Dim sCoolDesktopDirectory As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
        MsgBox(sCoolDesktopDirectory)

%USERPROFILE%\Desktop\myfile.txt

this works fine to open a file but to open a folder use

explorer.exe %USERPROFILE%\Desktop\Folder

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.