Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2015-01-28
1
Medium Priority
?
135 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
1 Comment
 
LVL 35

Accepted Solution

by:
it_saige earned 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

In this modest contribution, I want to share with the IT community (especially system administrators, IT Support Engineers and IT Help Desks) about Windows crashes/hangs and how to deal with these particular problems.
The article covers five tools all IT professionals should know about, as they up productivity by a great deal!
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

963 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