Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
Wallarn
- Posts: 9
- Joined: 13 Jan 2014 02:27
#1
Post
by Wallarn » 13 Jan 2014 05:19
Hello
Is there any way i can create a .url file on a computer using %computername%
i need to grab the actual hostname and paste it into the .url file automatic
so other users can just doubleclick on the file and start working
[InternetShortcut]
URL=http://hostname/xxx:xx
thanks for any help

-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#2
Post
by foxidrive » 13 Jan 2014 05:26
What do you want the URL file to do? Allow access to your computer?
-
Wallarn
- Posts: 9
- Joined: 13 Jan 2014 02:27
#3
Post
by Wallarn » 13 Jan 2014 05:36
i'm creating this file on every computer i install a webserver
i then want to copy the .url file to another computer on the network so other users can reach the webserver
i have about 180 diffrent webservers to do this on so any minutes i can save on each install would be much welcome

From the server i want to save a internet shorcut and save it to a share on the network so users can click on it and reach the www server
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#4
Post
by foxidrive » 13 Jan 2014 05:40
Have you tested this creating one manually?
Will a http link work within a LAN?
-
Wallarn
- Posts: 9
- Joined: 13 Jan 2014 02:27
#5
Post
by Wallarn » 13 Jan 2014 06:57
Yes i have created this file manualy and it works
but i would like to make it automagic

i want to doubleclick on a .bat file and grab hostname on the computer i installed the webserver on and save it as a Favorite
and then i want to share the favorite on a networkshare so other can reach the server
-
Wallarn
- Posts: 9
- Joined: 13 Jan 2014 02:27
#6
Post
by Wallarn » 13 Jan 2014 07:08
if i edit the favorite xxx.url
[InternetShortcut]
URL=http://locahost/xxxx:8081
can i grab the hostname %computername% and paste it into the url? with a .bat script or any other metode vbs
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#7
Post
by foxidrive » 13 Jan 2014 07:41
Wallarn wrote:if i edit the favorite xxx.url
[InternetShortcut]
URL=http://locahost/xxxx:8081
Even if you fix the typo I don't think that will work using localhost.
-
Wallarn
- Posts: 9
- Joined: 13 Jan 2014 02:27
#8
Post
by Wallarn » 13 Jan 2014 07:59
I dont want to use localhost
i want to grab the hostname of the computer and paste that into the .url file i get
if i type %computername% in cmd
i get this
C:\>echo %computername%
ANTDT001
i want to grab ANTDT001 and paste that into my .url file
can this be done with a batchscript? so it replaces whatever hostname i have in the .url
[InternetShortcut]
URL=http://whateverhostname
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#9
Post
by foxidrive » 13 Jan 2014 08:07
if you give this url file to another person on your LAN then can they access your webserver?
Code: Select all
[InternetShortcut]
URL=http://ANTDT001
-
Wallarn
- Posts: 9
- Joined: 13 Jan 2014 02:27
#10
Post
by Wallarn » 13 Jan 2014 08:46
yes but then i have 179 other server with diffrent hostname i want to modify this .url file with
if i put it this way
can i grab what the command echo %computername% outputs in cmd and past it into a text file and replace a certain word in a text file?
-
Wallarn
- Posts: 9
- Joined: 13 Jan 2014 02:27
#11
Post
by Wallarn » 13 Jan 2014 09:07
C:\>echo %computername% >>xxxurl.url but i want to specify where in the text file it should be pasted
Hope you understand what and where i'm going with this

-
penpen
- Expert
- Posts: 2009
- Joined: 23 Jun 2013 06:15
- Location: Germany
#12
Post
by penpen » 13 Jan 2014 11:36
Do you want something like this?
Code: Select all
(
echo [InternetShortcut]
echo URL=http://%computername%
) > xxxurl.url
It seems strange, as you seem to know, how to create such a file.
penpen
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#13
Post
by foxidrive » 14 Jan 2014 00:59
foxidrive wrote:if you give this url file to another person on your LAN then can they access your webserver?
Code: Select all
[InternetShortcut]
URL=http://ANTDT001
You said that it works - did you test it on another machine in your LAN?
I'm trying to tell you that a HTTP link like that won't work - creating it is trivial but it seems that you're not telling the truth about what you want.
-
Wallarn
- Posts: 9
- Joined: 13 Jan 2014 02:27
#14
Post
by Wallarn » 14 Jan 2014 02:25
I'm installing a program that have a builtin webserver on computer 1 at a store
that store has 9 other client computers
these 9 client have a drive mapped to the server \\computer1\x
in share x i have saved the file xxxx.url that targets \\computer1\xxx:8081
when a user that uses a cliemt clicks on the url he then gets directed to computer1's www server
You said that it works - did you test it on another machine in your LAN?
I'm trying to tell you that a HTTP link like that won't work - creating it is trivial but it seems that you're not telling the truth about what you want.
Yes i have tested that link and it works, why do you think I'm lying?
http://imgur.com/YM87lul,IQzxs6w#0http://imgur.com/YM87lul,IQzxs6w#1
-
Wallarn
- Posts: 9
- Joined: 13 Jan 2014 02:27
#15
Post
by Wallarn » 14 Jan 2014 02:30
penpen wrote:Do you want something like this?
Code: Select all
(
echo [InternetShortcut]
echo URL=http://%computername%
) > xxxurl.url
It seems strange, as you seem to know, how to create such a file.
penpen
I cant use the variable i need to grab the actual hostname and save it in the file, this is what i want the script to do
if i'm seated on a client and use the variable %computername% the url would link to the clients hostname and that's not where the www server are installed