LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Run command prompt as administrator using system exec.vi

Solved!
Go to solution

Any suggestions on how to go about that?  The problem I run into is that I am opening a command prompt with a command prompt and not sure how to pass the batch file to the secondary command prompt.

-ncm
0 Kudos
Message 11 of 18
(5,683 Views)

The system exec should call the batchfile directly.

 

Something like cmd /c "MyBatchFile.bat"

0 Kudos
Message 12 of 18
(5,664 Views)

Dear Sir,

 

Please help me to run command prompt in administrator and have to send a command for example "arp -d 192.168.9.121" programmatically using system execute VI.

 

Please help me with example.

 

 

Regards,

S Nagaraju

0 Kudos
Message 13 of 18
(5,469 Views)

Hello,

 

Can you be more specific on the problem you're encountering? Are you receiving an error code?

0 Kudos
Message 14 of 18
(5,443 Views)

Dear sir,

 

I am not receiving any errors. Actually we are developing dynamic IP address for one of our customized FPGA board to change IP address for user convenient. Every time user changes to new IP address previous IP should be deleted from the cache memory. For that we have to send one command to command prompt i.e. “arp –d IP address” for example “arp –d 192.168.9.121”. This command will work only administrator command prompt and its send programmatically using system execute.vi and it will work for executables also.

 

Please help me how to send the command to administrator command prompt.

 

Regards,

S Nagaraju

0 Kudos
Message 15 of 18
(5,423 Views)

You can do it with a VBS script like this :

 

you need to fill in your own DOMAIN   ADMIN  & PASSWORD in below script ,   (Save below text as 'arp.vbs')

 

Option explicit
Dim oShell
set oShell= Wscript.CreateObject("WScript.Shell")
oShell.Run "RunAs /user:DOMAIN\ADMIN ""cmd"
WScript.Sleep 100
oShell.Sendkeys "PASSWORD"
WScript.Sleep 500

REM **** HERE YOU PUT YOUR ARP cmd ****
oShell.Sendkeys "arp –d 192.168.9.121~"

WScript.Sleep 1000
oShell.Sendkeys "exit~"
Wscript.Quit

 

0 Kudos
Message 16 of 18
(5,405 Views)

Dear sir,

 

I don’t have much Knowledge on VBS Scripts.

 

Can you please implement in LabVIEW.

 

Regards,

S Nagaraju

0 Kudos
Message 17 of 18
(5,388 Views)

Well you have to run a VBS script like this,

 

cscript system exe.png

 

The file "devmgmt.vbs" contains the text I have posted in previous thread.

The working dir is where your file is located!

 

Important is that you do not take out the sleeps, they might need some fine tuning...   the runas-cmd will launch a 2nd prompt and you need to be sure it's already there before you do your ARP cmd!

 

good luck!

0 Kudos
Message 18 of 18
(5,367 Views)