Jump to content

General Query


Recommended Posts

you cannot order a script to stay, you can figure out why it quits and take care of that. care to post your "That worked!" code?

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

I'm well aware that I cannot order it to stay. As of that code, Nothing much. As you said, I put it where it was creating an object.

Global $Services = ObjGet("winmgmts:\\" & $computer & "\root\cimv2")
If @error Then MsgBox(4144,"Error", "This user account is not authorised for access to the remote machine.")
Global $ServicesList = $Services.ExecQuery("SELECT * FROM Win32_Service)

 

Link to comment
Share on other sites

so you try to create an object, it fails and displays a message. then you try to use that object, which was not created. brilliant.

it's like seeing a road sign saying "Stop!" and you go "oh, that's a nice message" but you keep driving anyway, and moments later you are surprised you hit a brick wall.

EDIT: P.S. why use ObjGet rather than ObjCreate? ObjCreate allows you to specify credentials for the remote target.

 

Edited by orbs

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

Okay. That was a nice one. But the values of $computer is received from a combo box. So in case, the access does not get through, they can change the values themselves. Also, I think it looks good when you can close it and it does not look like it crashed. And  I use ObjGet Because I think that's how it works. I'm not sure though. When I tried ObjCreate instead of ObjGet, things went downhill. Moreover, I do not want to hard code credentials in the script.

This is the dialog box that I desire. I borrowed that from mstsc. But that'll be an extended functionality. My primary concern is that the script should not exit.

573c214e4107c_2016-05-1813_22_05-General

 

See that "use another account" there? That's what I wanna be able to do.

Edited by pranaynanda
Link to comment
Share on other sites

you need to make it so that if there is an error, the script returns to the combo box. for example, put the entire thing in a function, and then the error check would be:

Local $Services = ObjGet("winmgmts:\\" & $computer & "\root\cimv2")
If @error Then
    MsgBox(4144,"Error", "This user account is not authorised for access to the remote machine.")
    Return
EndIf
Local $ServicesList = $Services.ExecQuery("SELECT * FROM Win32_Service)

Note i switched all "Global" to "Local" because you're in a function now.

another way: i assume that if you have a combo box, then you have a GUI; and if you have a GUI, you have a main loop; and if you have a main loop, then when the user selects a value from the combo box and orders your script to accept the value and continue, your script exits the main loop and goes on to the Obj stuff. in this case, you can check the object creation before the loop exits, and do not exit the loop if there was an error.

P.S. sorry if my last post seems a bit harsh.

EDIT: and forget about that dialog. it's for manually starting an executable as another user. you can of course let the user start your script like that, thus eliminating all your problems.

Edited by orbs

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...