Hello

I now have a working script that displays a .htm file when a user logs on to their computer. (thanks to alot of help from a member at this site!!). My next issue is that because a lot of my users are using CITRIX for work, then they are getting this .hmt file appear when they open a new appliction (as this runs the logon script again!!). Is there a way of saying the following in code

If computer_name = Server1 or Server2 then

exit

else

Run rest of script??

As you have probably guessed i am not very good at coding but i have been working hard with this and can see the light at the end of the tunnel

Thanks to anyone who can help

Regards

Gareth

;) Me again!

Dim objNetwork
Set objNetwork = Wscript.CreateObject("Wscript.Network")
computerName = objNetwork.ComputerName

Will Return the computer name in question. Then you have pretty much already answered your own question with your psuedo-code above. (By The Way, You can put your code in the little boxes like the one above by putting them in code tags (without the spaces) [ CODE ] code here [ /CODE ]). Of Course, WScript.Quit might be better than exit!!!

I don't know how you plan to keep track of what people have logged in, so you know how is logged in and who isn't. I would suggest maybe a temporary file, that holds a list of computer names of people who have logged in (if the script runs on the server), or a file that notifies the script whenever they are logged in. Then, when they log out, just remove the file (or if on a server, the computer name from the file).
Good Luck!

OK

This is what i have so far

on error resume next

Dim objNetwork
Set objNetwork = Wscript.CreateObject("Wscript.Network")
computerName = objNetwork.ComputerName

If objNetwork.Computername = "SERVER_NAME" then

WScript.Quit

else

dim oIE
Set oIE = WScript.CreateObject("InternetExplorer.Application")


TheDay = WeekdayName(Weekday(Date))

if Theday = "Friday" then
	oIE.Navigate "file://FILENAME"
	oIE.Visible = True
else

end if
set oIE = Nothing

WScript.Quit

public function ReturnDay
	RawDate = FormatDateTime(Now(), 1)
	Parts = split(RawDate, ",")
	ReturnDay = Parts(0)
end function

the problem is i am getting a compile error..

Error: Expected 'End'
Code: 800A03F6

any ideas

Cheers again for the help

I don't care to harp, but you know, if your code was indented, you would be able to see it a lot more clearly. Let me show you:

on error resume next

Dim objNetwork
Set objNetwork = Wscript.CreateObject("Wscript.Network")
computerName = objNetwork.ComputerName

If objNetwork.Computername = "SERVER_NAME" then

	WScript.Quit

else

	dim oIE
	Set oIE = WScript.CreateObject("InternetExplorer.Application")


	TheDay = WeekdayName(Weekday(Date))

	if Theday = "Friday" then
		oIE.Navigate "file://FILENAME"
		oIE.Visible = True
	else

	end if
	
	set oIE = Nothing


WScript.Quit

public function ReturnDay
	RawDate = FormatDateTime(Now(), 1)
	Parts = split(RawDate, ",")
	ReturnDay = Parts(0)
end function

Now, after set oIE = Nothing, and before WScript.Quit, there should be an "end if." After indenting it, if you just follow the if, down to else, and then down, you see there is no end if for that if block :)

Sorry for the messy coding..

That worked again..

Cheers

I will try and not bother you too much in the future, have a good weekend

Gareth

No No NO! By you posting questions, it gives me something to do other than chat in the IRC on this page :) Please, any questions at all, feel free to post! It's never a bother!

As for the code, Sometimes I write messy code, I just remember you saying that you were new to programming, and I am trying to help you out for the future. It's a lot easier to see, indented.... I never used to indent when I was new to code ;)

Hello,

I have managed to get that to exclude one machine, but i can not get it to exclude 2.. Where am i going wrong

on error resume next

Dim objNetwork
Set objNetwork = Wscript.CreateObject("Wscript.Network")
computerName = objNetwork.ComputerName

If objNetwork.Computername = "COMPUTER1" or "COMPUTER2" then

	WScript.Quit

else

	dim oIE
	Set oIE = WScript.CreateObject("InternetExplorer.Application")


	TheDay = WeekdayName(Weekday(Date))

	if Theday = "Tuesday" then
		oIE.Navigate "file://cih_data\IT\public\CIHStaffNews.htm"
		oIE.Visible = True
	else

	end if
	set oIE = Nothing

end if

WScript.Quit

public function ReturnDay
	RawDate = FormatDateTime(Now(), 1)
	Parts = split(RawDate, ",")
	ReturnDay = Parts(0)
end function

Any help again would be nice

Gareth

It's in your if statement. When you use an OR, you have to apply a complete comparison on both sides. so:

If objNetwork.Computername = "COMPUTER1" or objNetwork.Computername = "COMPUTER2" then
     WScript.Quit
else

Cheers, had almost got there with that one.. Actually think i tried that method but with errors else where. It is working now..

Thanks Again

Have a nice day :lol:

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.