Solved

Dymanically adding an IP address to the end of a shortcut command line

Posted on 2015-01-28
1
121 Views
Last Modified: 2015-02-13
I have a program that runs the command below in the properties section of a shortcut. 10.10.10.1 is the IP address of the PC that the shortcut is running from however, the PCs will no longer have static addresses so I need to find a way to have the current IP address of the PC added to the end of this command dynamically. I was told to replace the IP address with %IP% but, that didn't work. Is there a way that I can have the current IP of the PC appended to this command line. The operating system is Windows 7

C:\dbcsc\dbcsc.exe 10.10.2.2  master -cfg=dbcdxl.cfg SMARTCLIENT DBC_PORT=  DBC_IP=10.10.10.1
0
Comment
Question by:jfholloway
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 34

Accepted Solution

by:
it_saige earned 500 total points
ID: 40575969
You could use a batch to set an environment variable for the local ip and then set the 'DBC_IP=%whateverthevariablenameis%.

Something like:
@cls
echo off
FOR /F "tokens=4 delims= " %%i in ('route print ^| find " 0.0.0.0"') DO SETX LOCALIP %%i /M

Open in new window

In a batch produces the local ip in a system environment variable called LOCALIP.  You could then have the shortcut reference this:
C:\dbcsc\dbcsc.exe 10.10.2.2  master -cfg=dbcdxl.cfg SMARTCLIENT DBC_PORT=  DBC_IP=%LOCALIP%

Open in new window

The batch itself, could be called as part of a Machine Startup script or Login script.

-saige-
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
This article shows how to use a free utility called 'Parkdale' to easily test the performance and benchmark any Hard Drive(s) installed in your computer. We also look at RAM Disks and their speed comparisons.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question