Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Password authorized program lanch failure

Status
Not open for further replies.

needadonut

Technical User
Jul 22, 2013
4
I am fairly new to vbscript, and have been experimenting with mashing together 2 different scripts. Well, of course things didnt work (Stupid me) and im not experienced enough to fix them. Heres the code:

dim password
dim objshell
dim answer
password="airvent1"

do
ask=inputbox("Enter password below","Security System","Enter Password")
select case ask
case password
answer=true
x=msgbox("Password accepted",0,"Password accepted")
'objShell.Run("""J:\Program Files\Mozilla Firefox\firefox.exe""")
Set objShell = Nothing
wscript.quit
end select
answer=false
x=msgbox("Access Denied",16,"Access Denied")
if vbOk then wscript.quit
loop until answer=true

PROBLEM: The application isnt starting. No error message or anything. I type the password, the "password accepted" box comes up, then the script ends. Please help me.

Please excuse me for my inexperienced-ness
 
For starters, remove the apostrophe; this causes all other characters to the right to be ignored.

What are you trying to accomplish with this script?
 
I removed the apostrophe and got an error: 800Ao1a8 Object required:" On line 12 charachter 1
I added the " to the front of line 12 and got an error: 800a0400 Expected statement On line 12 char. 1 I belive that means its the wrong thing in front?


Im trying to make it so Firefox requires a password to open
 
Before calling the objShell.Run method you should create the objShell object:
Set objShell = CreateObject("WScript.Shell")

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV. It worked. I guess an object cant be an object without being created, can it. Once again thanks.
 
Hi [thumbsup]
You can Try this code also :
Code:
dim password
dim objshell
dim answer
password="airvent1"
Set objShell = CreateObject("WScript.Shell") 
Do
	ask=inputbox("Enter password below","Security System","Enter Password")
	select case ask
	case password
		answer=true
		x=msgbox("Password accepted",64,"Password accepted")
		Command = "Cmd /c CD %Programfiles%\Mozilla Firefox\ | Start Firefox.exe"
		Exec = objShell.Run(Command,0,False)
		Set objShell = Nothing
		wscript.quit
	end select
	answer=false
	x=msgbox("Access Denied",16,"Access Denied")
'if vbOk then wscript.quit
Loop until answer=true
 
So that would be an execute, not a run, right? whats is the difference between them?
 
So that would be an execute, not a run, right?
Depends... If you are asking what is going on in Crackoo's code, then, no, you are wrong. However, if you are asking what execution method should be used given the circumstance, then, yes, you are correct.

There are several differences. Chiefly,

.run:
mostly cmdline programs (ping, ipconfig, cmd)
errorlevel returned once the command ends
synchronous (no real-time output)

.exec():
mostly GUI programs (FireFox) however cmdline programs can also be executed when combined with "CMD"
no errorlevel returned
asynchronous (real-time output if the program is a cmdline program and the program argument supports it. [the output is stored in a text stream which can be accessed in real-time])

Considering FireFox.exe is a GUI program, nothing is being done with the returned errorlevel, and the command does not require an asynchronous behavior, I would suggest changing:
Code:
Command = "Cmd /c CD %Programfiles%\Mozilla Firefox\ | Start Firefox.exe"
Exec = objShell.Run(Command,0,False)

to

Code:
objShell.Exec("J:\Program Files\Mozilla Firefox\Firefox.exe")

-Geates

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top